analizators/U2U1209

This commit is contained in:
Anton Suhorukov 2022-01-18 17:43:46 +03:00
parent f1f7a82b39
commit 6c5792583a
11 changed files with 47 additions and 68 deletions

View File

@ -53,10 +53,8 @@ namespace ASC.Common.Logging
const string key = "cleanPeriod";
if (NLog.LogManager.Configuration.Variables.Keys.Contains(key))
if (LogManager.Configuration.Variables.TryGetValue(key, out var variable))
{
var variable = NLog.LogManager.Configuration.Variables[key];
if (variable != null && !string.IsNullOrEmpty(variable.Text))
{
int.TryParse(variable.Text, out value);

View File

@ -245,10 +245,7 @@ namespace ASC.Core.Common.Configuration
if (string.IsNullOrEmpty(value))
{
if (AllProps.ContainsKey(name))
{
value = AllProps[name];
}
AllProps.TryGetValue(name, out value);
}
return value;
@ -354,9 +351,9 @@ namespace ASC.Core.Common.Configuration
HandlerType = Type.GetType(additional[HandlerTypeKey]);
if (additional.ContainsKey(CdnKey))
if (additional.TryGetValue(CdnKey, out var value))
{
Cdn = GetCdn(additional[CdnKey]);
Cdn = GetCdn(value);
}
}

View File

@ -75,9 +75,8 @@ namespace ASC.Core.Data
foreach (var a in tenantAces)
{
var key = string.Concat(a.Tenant.ToString(), a.SubjectId.ToString(), a.ActionId.ToString(), a.ObjectId);
if (commonAces.ContainsKey(key))
if (commonAces.TryGetValue(key, out var common))
{
var common = commonAces[key];
commonAces.Remove(key);
if (common.Reaction == a.Reaction)
{

View File

@ -120,17 +120,14 @@ namespace ASC.Data.Storage.GoogleCloud
? new Uri(props["cnamessl"], UriKind.Absolute)
: new Uri("https://storage.googleapis.com/" + _bucket + "/", UriKind.Absolute);
if (props.ContainsKey("lower"))
if (props.TryGetValue("lower", out var value))
{
bool.TryParse(props["lower"], out _lowerCasing);
bool.TryParse(value, out _lowerCasing);
}
_json = props["json"];
if (props.ContainsKey("subdir"))
{
_subDir = props["subdir"];
}
props.TryGetValue("subdir", out _subDir);
return this;
}
@ -348,9 +345,9 @@ namespace ASC.Data.Storage.GoogleCloud
return PredefinedObjectAcl.Private;
}
if (_domainsAcl.ContainsKey(domain))
if (_domainsAcl.TryGetValue(domain, out var value))
{
return _domainsAcl[domain];
return value;
}
return _moduleAcl;
}

View File

@ -146,15 +146,12 @@ namespace ASC.Data.Storage.RackspaceCloud
_apiKey = props["apiKey"];
_username = props["username"];
if (props.ContainsKey("lower"))
if (props.TryGetValue("lower", out var value))
{
bool.TryParse(props["lower"], out _lowerCasing);
bool.TryParse(value, out _lowerCasing);
}
if (props.ContainsKey("subdir"))
{
_subDir = props["subdir"];
}
props.TryGetValue("subdir", out _subDir);
_public_container = props["public_container"];
@ -193,13 +190,13 @@ namespace ASC.Data.Storage.RackspaceCloud
var accounMetaData = client.GetAccountMetaData(_region);
string secretKey;
if (accounMetaData.ContainsKey("Temp-Url-Key"))
if (accounMetaData.TryGetValue("Temp-Url-Key", out secretKey))
{
secretKey = accounMetaData["Temp-Url-Key"];
}
else
{
secretKey = ASC.Common.Utils.RandomString.Generate(64);
secretKey = Common.Utils.RandomString.Generate(64);
accounMetaData.Add("Temp-Url-Key", secretKey);
client.UpdateAccountMetadata(accounMetaData, _region);
}
@ -380,9 +377,9 @@ namespace ASC.Data.Storage.RackspaceCloud
return ACL.Auto;
}
if (_domainsAcl.ContainsKey(domain))
if (_domainsAcl.TryGetValue(domain, out var value))
{
return _domainsAcl[domain];
return value;
}
return _moduleAcl;
}

View File

@ -98,9 +98,9 @@ namespace ASC.Data.Storage.S3
return S3CannedACL.Private;
}
if (_domainsAcl.ContainsKey(domain))
if (_domainsAcl.TryGetValue(domain, out var value))
{
return _domainsAcl[domain];
return value;
}
return _moduleAcl;
}
@ -1116,40 +1116,37 @@ namespace ASC.Data.Storage.S3
_secretAccessKeyId = props["secretaccesskey"];
_bucket = props["bucket"];
if (props.ContainsKey("recycleDir"))
props.TryGetValue("recycleDir", out _recycleDir);
if (props.TryGetValue("region", out var region) && !string.IsNullOrEmpty(region))
{
_recycleDir = props["recycleDir"];
_region = region;
}
if (props.ContainsKey("region") && !string.IsNullOrEmpty(props["region"]))
if (props.TryGetValue("serviceurl", out var url) && !string.IsNullOrEmpty(url))
{
_region = props["region"];
_serviceurl = url;
}
if (props.ContainsKey("serviceurl") && !string.IsNullOrEmpty(props["serviceurl"]))
if (props.TryGetValue("forcepathstyle", out var style))
{
_serviceurl = props["serviceurl"];
}
if (props.ContainsKey("forcepathstyle"))
{
if (bool.TryParse(props["forcepathstyle"], out var fps))
if (bool.TryParse(style, out var fps))
{
_forcepathstyle = fps;
}
}
if (props.ContainsKey("usehttp"))
if (props.TryGetValue("usehttp", out var use))
{
if (bool.TryParse(props["usehttp"], out var uh))
if (bool.TryParse(use, out var uh))
{
_useHttp = uh;
}
}
if (props.ContainsKey("sse") && !string.IsNullOrEmpty(props["sse"]))
if (props.TryGetValue("sse", out var sse) && !string.IsNullOrEmpty(sse))
{
_sse = (props["sse"].ToLower()) switch
_sse = sse.ToLower() switch
{
"none" => ServerSideEncryptionMethod.None,
"aes256" => ServerSideEncryptionMethod.AES256,
@ -1166,23 +1163,17 @@ namespace ASC.Data.Storage.S3
? new Uri(props["cnamessl"], UriKind.Absolute)
: new Uri($"https://s3.{_region}.amazonaws.com/{_bucket}/", UriKind.Absolute);
if (props.ContainsKey("lower"))
if (props.TryGetValue("lower", out var lower))
{
bool.TryParse(props["lower"], out _lowerCasing);
bool.TryParse(lower, out _lowerCasing);
}
if (props.ContainsKey("cloudfront"))
if (props.TryGetValue("cloudfront", out var front))
{
bool.TryParse(props["cloudfront"], out _revalidateCloudFront);
}
if (props.ContainsKey("distribution"))
{
_distributionId = props["distribution"];
bool.TryParse(front, out _revalidateCloudFront);
}
if (props.ContainsKey("subdir"))
{
_subDir = props["subdir"];
}
props.TryGetValue("distribution", out _distributionId);
props.TryGetValue("subdir", out _subDir);
return this;
}

View File

@ -179,9 +179,9 @@ namespace ASC.Feed.Data
feedsIteration = GetFeedsInternal(filter);
foreach (var feed in feedsIteration)
{
if (feeds.ContainsKey(feed.GroupId))
if (feeds.TryGetValue(feed.GroupId, out var value))
{
feeds[feed.GroupId].Add(feed);
value.Add(feed);
}
else
{

View File

@ -133,9 +133,9 @@ namespace ASC.MessagingSystem.DbSender
ClientInfo clientInfo;
if (dict.ContainsKey(message.UAHeader))
if (dict.TryGetValue(message.UAHeader, out clientInfo))
{
clientInfo = dict[message.UAHeader];
}
else
{

View File

@ -99,7 +99,7 @@ namespace ASC.MessagingSystem
var items = value.Split(',');
if (items.Count == 0) return null;
if (items.Length == 0) return null;
return new MessageTarget(Option)
{

View File

@ -201,9 +201,9 @@ namespace ASC.Feed.Aggregator
{
dictionary = new Dictionary<Guid, int>();
}
if (dictionary.ContainsKey(userGuid))
if (dictionary.TryGetValue(userGuid, out var value))
{
++dictionary[userGuid];
++value;
}
else
{

View File

@ -140,9 +140,9 @@ namespace ASC.UrlShortener.Svc
if (splited.Length < 2) continue;
if (dict.ContainsKey(splited[0]))
if (dict.TryGetValue(splited[0], out var value))
{
startInfo.EnvironmentVariables.Add("sql:" + dict[splited[0]], splited[1]);
startInfo.EnvironmentVariables.Add("sql:" + dict[value], splited[1]);
}
}