qol: inline variable declaration
This commit is contained in:
@@ -705,9 +705,7 @@ namespace Disco.Services
|
||||
#region Force Close
|
||||
public static bool CanCloseForced(this Job j)
|
||||
{
|
||||
List<string> reasons;
|
||||
|
||||
return CanCloseForced(j, out reasons);
|
||||
return CanCloseForced(j, out _);
|
||||
}
|
||||
public static bool CanCloseForced(this Job j, out List<string> Reasons)
|
||||
{
|
||||
|
||||
@@ -76,9 +76,8 @@ namespace Disco.Services.Jobs.JobQueues
|
||||
public JobQueueToken UpdateQueue(JobQueue JobQueue)
|
||||
{
|
||||
var token = JobQueueToken.FromJobQueue(JobQueue);
|
||||
JobQueueToken existingToken;
|
||||
|
||||
if (_Cache.TryGetValue(JobQueue.Id, out existingToken))
|
||||
if (_Cache.TryGetValue(JobQueue.Id, out var existingToken))
|
||||
{
|
||||
if (_Cache.TryUpdate(JobQueue.Id, token, existingToken))
|
||||
{
|
||||
@@ -103,8 +102,7 @@ namespace Disco.Services.Jobs.JobQueues
|
||||
}
|
||||
public bool RemoveQueue(int JobQueueId)
|
||||
{
|
||||
JobQueueToken token;
|
||||
if (_Cache.TryRemove(JobQueueId, out token))
|
||||
if (_Cache.TryRemove(JobQueueId, out _))
|
||||
{
|
||||
CalculateSubjectCache();
|
||||
return true;
|
||||
@@ -116,8 +114,7 @@ namespace Disco.Services.Jobs.JobQueues
|
||||
}
|
||||
public JobQueueToken GetQueue(int JobQueueId)
|
||||
{
|
||||
JobQueueToken token;
|
||||
if (_Cache.TryGetValue(JobQueueId, out token))
|
||||
if (_Cache.TryGetValue(JobQueueId, out var token))
|
||||
return token;
|
||||
else
|
||||
return null;
|
||||
@@ -128,8 +125,7 @@ namespace Disco.Services.Jobs.JobQueues
|
||||
}
|
||||
private IEnumerable<JobQueueToken> GetQueuesForSubject(string SubjectId)
|
||||
{
|
||||
List<JobQueueToken> tokens;
|
||||
if (_SubjectCache.TryGetValue(SubjectId, out tokens))
|
||||
if (_SubjectCache.TryGetValue(SubjectId, out var tokens))
|
||||
return tokens;
|
||||
else
|
||||
return Enumerable.Empty<JobQueueToken>();
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Disco.Services.Jobs.JobQueues
|
||||
{
|
||||
public static class JobQueueService
|
||||
{
|
||||
private const string _cacheHttpRequestKey = "Disco_UserQueuesToken_{0}";
|
||||
private const string _cacheHttpRequestKey = "Disco_UserQueuesToken";
|
||||
private static Cache _cache;
|
||||
|
||||
public static void Initialize(DiscoDataContext Database)
|
||||
@@ -168,21 +168,19 @@ namespace Disco.Services.Jobs.JobQueues
|
||||
}
|
||||
public static ReadOnlyCollection<JobQueueToken> UsersQueues(AuthorizationToken UserAuthorization)
|
||||
{
|
||||
string cacheKey = string.Format(_cacheHttpRequestKey, UserAuthorization.User.UserId);
|
||||
ReadOnlyCollection<JobQueueToken> tokens = null;
|
||||
|
||||
// Check for ASP.NET
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
tokens = (ReadOnlyCollection<JobQueueToken>)HttpContext.Current.Items[_cacheHttpRequestKey];
|
||||
}
|
||||
|
||||
if (tokens == null)
|
||||
{
|
||||
var subjectIds = (new string[] { UserAuthorization.User.UserId }).Concat(UserAuthorization.GroupMembership);
|
||||
tokens = _cache.GetQueuesForSubject(subjectIds);
|
||||
|
||||
HttpContext.Current.Items[_cacheHttpRequestKey] = tokens;
|
||||
if (HttpContext.Current != null)
|
||||
HttpContext.Current.Items[_cacheHttpRequestKey] = tokens;
|
||||
}
|
||||
|
||||
return tokens;
|
||||
|
||||
@@ -53,14 +53,13 @@ namespace Disco.Services.Jobs
|
||||
|
||||
public override Task OnConnected()
|
||||
{
|
||||
int jobId;
|
||||
string jobIdParam;
|
||||
|
||||
jobIdParam = Context.QueryString["JobId"];
|
||||
|
||||
if (string.IsNullOrWhiteSpace(jobIdParam))
|
||||
throw new ArgumentNullException("JobId");
|
||||
if (!int.TryParse(jobIdParam, out jobId))
|
||||
if (!int.TryParse(jobIdParam, out var jobId))
|
||||
throw new ArgumentException("An integer was expected", "JobId");
|
||||
|
||||
var userAuth = UserService.GetAuthorization(Context.User.Identity.Name);
|
||||
|
||||
@@ -198,8 +198,7 @@ namespace Disco.Services.Jobs.Noticeboards
|
||||
.ToDictionary(dsn => dsn,
|
||||
dsn =>
|
||||
{
|
||||
IHeldDeviceItem item;
|
||||
items.TryGetValue(dsn, out item);
|
||||
items.TryGetValue(dsn, out var item);
|
||||
return item;
|
||||
});
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ namespace Disco.Services.Jobs.Noticeboards
|
||||
.ToDictionary(userId => userId,
|
||||
userId =>
|
||||
{
|
||||
IHeldDeviceItem item;
|
||||
items.TryGetValue(userId, out item);
|
||||
items.TryGetValue(userId, out var item);
|
||||
return item;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user