qol: inline variable declaration
This commit is contained in:
@@ -143,13 +143,12 @@ namespace Disco.Services.Users
|
||||
{
|
||||
var cache = _Cache;
|
||||
|
||||
Tuple<User, AuthorizationToken, DateTime> record;
|
||||
if (cache.TryGetValue(UserId, out record))
|
||||
if (cache.TryGetValue(UserId, out var record))
|
||||
{
|
||||
if (record.Item3 > DateTime.Now)
|
||||
return record;
|
||||
else
|
||||
cache.TryRemove(UserId, out record);
|
||||
cache.TryRemove(UserId, out _);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -158,11 +157,10 @@ namespace Disco.Services.Users
|
||||
{
|
||||
var cache = _Cache;
|
||||
|
||||
Tuple<User, AuthorizationToken, DateTime> record = new Tuple<User, AuthorizationToken, DateTime>(Record.Item1, Record.Item2, DateTime.Now.AddTicks(CacheTimeoutTicks));
|
||||
var record = new Tuple<User, AuthorizationToken, DateTime>(Record.Item1, Record.Item2, DateTime.Now.AddTicks(CacheTimeoutTicks));
|
||||
if (cache.ContainsKey(UserId))
|
||||
{
|
||||
Tuple<User, AuthorizationToken, DateTime> oldRecord;
|
||||
if (cache.TryGetValue(UserId, out oldRecord))
|
||||
if (cache.TryGetValue(UserId, out var oldRecord))
|
||||
{
|
||||
cache.TryUpdate(UserId, record, oldRecord);
|
||||
return record;
|
||||
@@ -174,8 +172,7 @@ namespace Disco.Services.Users
|
||||
|
||||
internal static bool InvalidateRecord(string UserId)
|
||||
{
|
||||
Tuple<User, AuthorizationToken, DateTime> userRecord;
|
||||
return _Cache.TryRemove(UserId, out userRecord);
|
||||
return _Cache.TryRemove(UserId, out _);
|
||||
}
|
||||
|
||||
internal static void CleanStaleCache()
|
||||
@@ -185,11 +182,10 @@ namespace Disco.Services.Users
|
||||
var userIds = cache.Keys.ToArray();
|
||||
foreach (string userId in userIds)
|
||||
{
|
||||
Tuple<User, AuthorizationToken, DateTime> record;
|
||||
if (cache.TryGetValue(userId, out record))
|
||||
if (cache.TryGetValue(userId, out var record))
|
||||
{
|
||||
if (record.Item3 <= DateTime.Now)
|
||||
cache.TryRemove(userId, out record);
|
||||
cache.TryRemove(userId, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@ namespace Disco.Services.Users.UserFlags
|
||||
|
||||
public UserFlag GetUserFlag(int UserFlagId)
|
||||
{
|
||||
UserFlag item;
|
||||
if (_Cache.TryGetValue(UserFlagId, out item))
|
||||
if (_Cache.TryGetValue(UserFlagId, out var item))
|
||||
return item;
|
||||
else
|
||||
return null;
|
||||
@@ -49,8 +48,7 @@ namespace Disco.Services.Users.UserFlags
|
||||
|
||||
public UserFlag Remove(int UserFlagId)
|
||||
{
|
||||
UserFlag item;
|
||||
if (_Cache.TryRemove(UserFlagId, out item))
|
||||
if (_Cache.TryRemove(UserFlagId, out var item))
|
||||
return item;
|
||||
else
|
||||
return null;
|
||||
|
||||
@@ -57,10 +57,9 @@ namespace Disco.Services.Users.UserFlags
|
||||
|
||||
public static bool TryGetManagedGroup(UserFlag UserFlag, out UserFlagUserDevicesManagedGroup ManagedGroup)
|
||||
{
|
||||
ADManagedGroup managedGroup;
|
||||
string key = GetKey(UserFlag);
|
||||
|
||||
if (ActiveDirectory.Context.ManagedGroups.TryGetValue(key, out managedGroup))
|
||||
if (ActiveDirectory.Context.ManagedGroups.TryGetValue(key, out var managedGroup))
|
||||
{
|
||||
ManagedGroup = (UserFlagUserDevicesManagedGroup)managedGroup;
|
||||
return true;
|
||||
|
||||
@@ -57,10 +57,9 @@ namespace Disco.Services.Users.UserFlags
|
||||
|
||||
public static bool TryGetManagedGroup(UserFlag UserFlag, out UserFlagUsersManagedGroup ManagedGroup)
|
||||
{
|
||||
ADManagedGroup managedGroup;
|
||||
string key = GetKey(UserFlag);
|
||||
|
||||
if (ActiveDirectory.Context.ManagedGroups.TryGetValue(key, out managedGroup))
|
||||
if (ActiveDirectory.Context.ManagedGroups.TryGetValue(key, out var managedGroup))
|
||||
{
|
||||
ManagedGroup = (UserFlagUsersManagedGroup)managedGroup;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user