IDE0019, IDE0020
This commit is contained in:
parent
96dd3cd657
commit
b426004f70
@ -92,8 +92,7 @@ namespace ASC.Common.Data
|
||||
return DBNull.Value;
|
||||
}
|
||||
|
||||
var @enum = value as Enum;
|
||||
if (@enum != null)
|
||||
if (value is Enum @enum)
|
||||
{
|
||||
return @enum.ToString("d");
|
||||
}
|
||||
|
@ -128,8 +128,7 @@ namespace ASC.Common.Data
|
||||
{
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
var dbManager = DisposableHttpContext.Current[databaseId] as DbManager;
|
||||
if (dbManager == null || dbManager.disposed)
|
||||
if (!(DisposableHttpContext.Current[databaseId] is DbManager dbManager) || dbManager.disposed)
|
||||
{
|
||||
var localDbManager = new DbManager(databaseId);
|
||||
var dbManagerAdapter = new DbManagerProxy(localDbManager);
|
||||
|
@ -46,8 +46,7 @@ namespace ASC.Common.DependencyInjection
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType)
|
||||
{
|
||||
var instantiableType = GetInstantiableType(destinationType);
|
||||
var elementCollection = value as DictionaryElementCollection;
|
||||
if (elementCollection == null || !(instantiableType != null))
|
||||
if (!(value is DictionaryElementCollection elementCollection) || !(instantiableType != null))
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
var dictionary = (IDictionary)Activator.CreateInstance(instantiableType);
|
||||
var genericArguments = instantiableType.GetGenericArguments();
|
||||
|
@ -77,8 +77,7 @@ namespace ASC.Common.DependencyInjection
|
||||
|
||||
private static TypeConverter GetTypeConverterFromName(string converterTypeName)
|
||||
{
|
||||
var typeConverter = Activator.CreateInstance(Type.GetType(converterTypeName, true)) as TypeConverter;
|
||||
if (typeConverter == null)
|
||||
if (!(Activator.CreateInstance(Type.GetType(converterTypeName, true)) is TypeConverter typeConverter))
|
||||
throw new ConfigurationErrorsException("");
|
||||
return typeConverter;
|
||||
}
|
||||
|
@ -65,8 +65,7 @@ namespace ASC.Common.Security.Authentication
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var a = obj as IAccount;
|
||||
return a != null && ID.Equals(a.ID);
|
||||
return obj is IAccount a && ID.Equals(a.ID);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
@ -62,8 +62,7 @@ namespace ASC.Common.Security.Authorizing
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var a = obj as Action;
|
||||
return a != null && a.ID == ID;
|
||||
return obj is Action a && a.ID == ID;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
@ -70,8 +70,7 @@ namespace ASC.Common.Security.Authorizing
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var r = obj as Role;
|
||||
return r != null && r.ID == ID;
|
||||
return obj is Role r && r.ID == ID;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
@ -51,8 +51,7 @@ namespace ASC.Common.Security
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as SecurityObjectId;
|
||||
return other != null &&
|
||||
return obj is SecurityObjectId other &&
|
||||
Equals(AzObjectIdHelper.GetFullObjectId(other), AzObjectIdHelper.GetFullObjectId(this));
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,7 @@ namespace ASC.Common.Threading.Workers
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
var disposable = Item as IDisposable;
|
||||
if (disposable != null)
|
||||
if (Item is IDisposable disposable)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
|
@ -69,8 +69,7 @@ namespace ASC.Core.Billing
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var t = obj as Tariff;
|
||||
return t != null && t.QuotaId == QuotaId;
|
||||
return obj is Tariff t && t.QuotaId == QuotaId;
|
||||
}
|
||||
}
|
||||
}
|
@ -256,8 +256,7 @@ namespace ASC.Core.Billing
|
||||
? GetBillingUrlCacheKey(tenant.Value)
|
||||
: string.Format("notenant{0}", !string.IsNullOrEmpty(affiliateId) ? "_" + affiliateId : "");
|
||||
key += quota.Visible ? "" : "0";
|
||||
var urls = cache.Get<Dictionary<string, Tuple<Uri, Uri>>>(key) as IDictionary<string, Tuple<Uri, Uri>>;
|
||||
if (urls == null)
|
||||
if (!(cache.Get<Dictionary<string, Tuple<Uri, Uri>>>(key) is IDictionary<string, Tuple<Uri, Uri>> urls))
|
||||
{
|
||||
urls = new Dictionary<string, Tuple<Uri, Uri>>();
|
||||
if (billingConfigured)
|
||||
|
@ -221,8 +221,7 @@ namespace ASC.Core.Caching
|
||||
GetChangesFromDb();
|
||||
|
||||
var key = GetRefCacheKey(tenant);
|
||||
var refs = cache.Get<UserGroupRefStore>(key) as IDictionary<string, UserGroupRef>;
|
||||
if (refs == null)
|
||||
if (!(cache.Get<UserGroupRefStore>(key) is IDictionary<string, UserGroupRef> refs))
|
||||
{
|
||||
refs = service.GetUserGroupRefs(tenant, default);
|
||||
cache.Insert(key, new UserGroupRefStore(refs), CacheExpiration);
|
||||
|
@ -118,8 +118,7 @@ namespace ASC.Core
|
||||
private IEnumerable<AzRecord> FilterAces(IEnumerable<AzRecord> aces, Guid subjectId, Guid actionId, ISecurityObjectId objectId)
|
||||
{
|
||||
var objId = AzObjectIdHelper.GetFullObjectId(objectId);
|
||||
var store = aces as AzRecordStore;
|
||||
return store != null ?
|
||||
return aces is AzRecordStore store ?
|
||||
store.Get(objId).Where(a => (a.SubjectId == subjectId || subjectId == Guid.Empty) && (a.ActionId == actionId || actionId == Guid.Empty)) :
|
||||
aces.Where(a => (a.SubjectId == subjectId || subjectId == Guid.Empty) && (a.ActionId == actionId || actionId == Guid.Empty) && a.ObjectId == objId);
|
||||
}
|
||||
|
@ -127,8 +127,7 @@ namespace ASC.Core
|
||||
{
|
||||
var newTenant = tenantService.SaveTenant(tenant);
|
||||
|
||||
var oldTenant = CallContext.GetData(CURRENT_TENANT) as Tenant;
|
||||
if (oldTenant != null) SetCurrentTenant(newTenant);
|
||||
if (CallContext.GetData(CURRENT_TENANT) is Tenant oldTenant) SetCurrentTenant(newTenant);
|
||||
|
||||
return newTenant;
|
||||
}
|
||||
|
@ -280,8 +280,7 @@ namespace ASC.Core
|
||||
|
||||
var refs = GetRefsInternal(tenant.TenantId);
|
||||
IEnumerable<UserGroupRef> userRefs = null;
|
||||
var store = refs as UserGroupRefStore;
|
||||
if (store != null)
|
||||
if (refs is UserGroupRefStore store)
|
||||
{
|
||||
userRefs = store.GetRefsByUser(userID);
|
||||
}
|
||||
@ -313,8 +312,7 @@ namespace ASC.Core
|
||||
|
||||
var refs = GetRefsInternal(tenantId);
|
||||
|
||||
var store = refs as UserGroupRefStore;
|
||||
if (store != null)
|
||||
if (refs is UserGroupRefStore store)
|
||||
{
|
||||
var userRefs = store.GetRefsByUser(userID);
|
||||
|
||||
|
@ -144,8 +144,7 @@ namespace ASC.Core
|
||||
|
||||
private static void NotifyEngine_AfterTransferRequest(NotifyEngine sender, NotifyRequest request)
|
||||
{
|
||||
var tenant = (request.Properties.Contains("Tenant") ? request.Properties["Tenant"] : null) as Tenant;
|
||||
if (tenant != null)
|
||||
if ((request.Properties.Contains("Tenant") ? request.Properties["Tenant"] : null) is Tenant tenant)
|
||||
{
|
||||
CoreContext.TenantManager.SetCurrentTenant(tenant);
|
||||
}
|
||||
|
@ -106,8 +106,7 @@ namespace ASC.Core
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var r = obj as AzRecord;
|
||||
return r != null &&
|
||||
return obj is AzRecord r &&
|
||||
r.Tenant == Tenant &&
|
||||
r.SubjectId == SubjectId &&
|
||||
r.ActionId == ActionId &&
|
||||
|
@ -234,8 +234,7 @@ namespace TMResourceData
|
||||
private Dictionary<string, string> GetResources()
|
||||
{
|
||||
var key = string.Format("{0}/{1}", filename, culture);
|
||||
var dic = cache.Get(key) as Dictionary<string, string>;
|
||||
if (dic == null)
|
||||
if (!(cache.Get(key) is Dictionary<string, string> dic))
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
|
@ -90,8 +90,7 @@ namespace ASC.Core
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var g = obj as Group;
|
||||
return g != null && g.Id == Id;
|
||||
return obj is Group g && g.Id == Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,8 +65,7 @@ namespace ASC.Core.Users
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var g = obj as GroupInfo;
|
||||
if (g == null) return false;
|
||||
if (!(obj is GroupInfo g)) return false;
|
||||
if (ID == Guid.Empty && g.ID == Guid.Empty) return ReferenceEquals(this, g);
|
||||
return g.ID == ID;
|
||||
}
|
||||
|
@ -169,8 +169,7 @@ namespace ASC.Core
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var p = obj as Partner;
|
||||
return p != null && p.Id == Id;
|
||||
return obj is Partner p && p.Id == Id;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
@ -74,8 +74,7 @@ namespace ASC.Core
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var r = obj as UserGroupRef;
|
||||
return r != null && r.Tenant == Tenant && r.UserId == UserId && r.GroupId == GroupId && r.RefType == RefType;
|
||||
return obj is UserGroupRef r && r.Tenant == Tenant && r.UserId == UserId && r.GroupId == GroupId && r.RefType == RefType;
|
||||
}
|
||||
|
||||
public static implicit operator UserGroupRef(UserGroupRefCacheItem cache)
|
||||
|
@ -116,8 +116,7 @@ namespace ASC.Core.Users
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var ui = obj as UserInfo;
|
||||
return ui != null && ID.Equals(ui.ID);
|
||||
return obj is UserInfo ui && ID.Equals(ui.ID);
|
||||
}
|
||||
|
||||
public CultureInfo GetCulture()
|
||||
|
@ -41,8 +41,7 @@ namespace ASC.Notify.Engine
|
||||
{
|
||||
get
|
||||
{
|
||||
var storage = CallContext.GetData(CallContext_Prefix) as Dictionary<string, ISendInterceptor>;
|
||||
if (storage == null)
|
||||
if (!(CallContext.GetData(CallContext_Prefix) is Dictionary<string, ISendInterceptor> storage))
|
||||
{
|
||||
storage = new Dictionary<string, ISendInterceptor>(10);
|
||||
CallContext.SetData(CallContext_Prefix, storage);
|
||||
|
@ -401,8 +401,7 @@ namespace ASC.Notify.Engine
|
||||
|
||||
private SendResponse SendDirectNotify(int tenantId, NotifyRequest request, ISenderChannel channel)
|
||||
{
|
||||
var recipient = request.Recipient as IDirectRecipient;
|
||||
if (recipient == null) throw new ArgumentException("request.Recipient not IDirectRecipient", "request");
|
||||
if (!(request.Recipient is IDirectRecipient recipient)) throw new ArgumentException("request.Recipient not IDirectRecipient", "request");
|
||||
|
||||
request.CurrentSender = channel.SenderName;
|
||||
|
||||
@ -488,8 +487,7 @@ namespace ASC.Notify.Engine
|
||||
{
|
||||
if (!stylers.ContainsKey(message.Pattern.Styler))
|
||||
{
|
||||
var styler = Activator.CreateInstance(Type.GetType(message.Pattern.Styler, true)) as IPatternStyler;
|
||||
if (styler != null)
|
||||
if (Activator.CreateInstance(Type.GetType(message.Pattern.Styler, true)) is IPatternStyler styler)
|
||||
{
|
||||
stylers.Add(message.Pattern.Styler, styler);
|
||||
}
|
||||
|
@ -59,8 +59,7 @@ namespace ASC.Notify.Model
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var a = obj as INotifyAction;
|
||||
return a != null && a.ID == ID;
|
||||
return obj is INotifyAction a && a.ID == ID;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
@ -71,8 +71,7 @@ namespace ASC.Notify.Patterns
|
||||
|
||||
private static void EventCartridgeReferenceInsertion(object sender, ReferenceInsertionEventArgs e)
|
||||
{
|
||||
var originalString = e.OriginalValue as string;
|
||||
if (originalString == null) return;
|
||||
if (!(e.OriginalValue is string originalString)) return;
|
||||
var lines = originalString.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (lines.Length == 0) return;
|
||||
e.NewValue = string.Empty;
|
||||
|
@ -60,8 +60,7 @@ namespace ASC.Notify.Patterns
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var p = obj as IPattern;
|
||||
return p != null && p.ID == ID;
|
||||
return obj is IPattern p && p.ID == ID;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
@ -59,8 +59,7 @@ namespace ASC.Notify.Patterns
|
||||
var xdoc = new XmlDocument();
|
||||
xdoc.LoadXml(xml);
|
||||
|
||||
var xformatter = xdoc.SelectSingleNode("/patterns/formatter") as XmlElement;
|
||||
if (xformatter != null)
|
||||
if (xdoc.SelectSingleNode("/patterns/formatter") is XmlElement xformatter)
|
||||
{
|
||||
var type = xformatter.GetAttribute("type");
|
||||
if (!string.IsNullOrEmpty(type))
|
||||
|
@ -77,8 +77,7 @@ namespace ASC.Notify.Recipients
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var recD = obj as IDirectRecipient;
|
||||
if (recD == null) return false;
|
||||
if (!(obj is IDirectRecipient recD)) return false;
|
||||
return Equals(recD.ID, ID);
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,7 @@ namespace ASC.Notify.Recipients
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var recGr = obj as IRecipientsGroup;
|
||||
if (recGr == null) return false;
|
||||
if (!(obj is IRecipientsGroup recGr)) return false;
|
||||
return Equals(recGr.ID, ID);
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,7 @@ namespace ASC.Core.Security.Authentication
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var a = obj as IUserAccount;
|
||||
return a != null && ID.Equals(a.ID);
|
||||
return obj is IUserAccount a && ID.Equals(a.ID);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
@ -122,8 +122,7 @@ namespace ASC.Core.Tenants
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var t = obj as Tenant;
|
||||
return t != null && t.TenantId == TenantId;
|
||||
return obj is Tenant t && t.TenantId == TenantId;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
@ -211,8 +211,7 @@ namespace ASC.Core.Tenants
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var q = obj as TenantQuota;
|
||||
return q != null && q.Id == Id;
|
||||
return obj is TenantQuota q && q.Id == Id;
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,8 +57,7 @@ namespace ASC.Core
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var v = obj as TenantVersion;
|
||||
return v != null && v.Id == Id;
|
||||
return obj is TenantVersion v && v.Id == Id;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
@ -56,8 +56,7 @@ namespace ASC.Common.Tests.Security.Authorizing
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var class1 = obj as Class1;
|
||||
return class1 != null && Equals(class1.Id, Id);
|
||||
return obj is Class1 class1 && Equals(class1.Id, Id);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
@ -334,8 +334,7 @@ namespace ASC.Common.Tests.Security.Authorizing
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var p = obj as PermissionRecord;
|
||||
return p != null && Id == p.Id;
|
||||
return obj is PermissionRecord p && Id == p.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,9 +145,8 @@ namespace ASC.Data.Storage.DiscStorage
|
||||
//Copy stream
|
||||
|
||||
//optimaze disk file copy
|
||||
var fileStream = buffered as FileStream;
|
||||
long fslen;
|
||||
if (fileStream != null && WorkContext.IsMono)
|
||||
if (buffered is FileStream fileStream && WorkContext.IsMono)
|
||||
{
|
||||
File.Copy(fileStream.Name, target, true);
|
||||
fslen = fileStream.Length;
|
||||
|
@ -40,9 +40,8 @@ namespace ASC.MessagingSystem
|
||||
try
|
||||
{
|
||||
var res = new List<string>();
|
||||
var ids = value as System.Collections.IEnumerable;
|
||||
|
||||
if (ids != null)
|
||||
if (value is System.Collections.IEnumerable ids)
|
||||
{
|
||||
res.AddRange(from object id in ids select id.ToString());
|
||||
}
|
||||
|
@ -107,8 +107,7 @@ namespace ASC.Web.Studio.Core.Quota
|
||||
result.UserStorageSize = CoreContext.Configuration.PersonalMaxSpace;
|
||||
|
||||
var webItem = WebItemManager.Instance[WebItemManager.DocumentsProductID];
|
||||
var spaceUsageManager = webItem.Context.SpaceUsageStatManager as IUserSpaceUsage;
|
||||
if (spaceUsageManager != null)
|
||||
if (webItem.Context.SpaceUsageStatManager is IUserSpaceUsage spaceUsageManager)
|
||||
result.UserUsedSize = spaceUsageManager.GetUserSpaceUsage(SecurityContext.CurrentAccount.ID);
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,7 @@ namespace ASC.Web.Core
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var m = obj as IWebItem;
|
||||
return m != null && ID == m.ID;
|
||||
return obj is IWebItem m && ID == m.ID;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
@ -106,8 +106,7 @@ namespace ASC.Web.Studio.Core.TFA
|
||||
|
||||
public static void DisableForUser(Guid guid)
|
||||
{
|
||||
var defaultSettings = new TfaAppUserSettings().GetDefault() as TfaAppUserSettings;
|
||||
if (defaultSettings != null)
|
||||
if (new TfaAppUserSettings().GetDefault() is TfaAppUserSettings defaultSettings)
|
||||
{
|
||||
defaultSettings.SaveForUser(guid);
|
||||
}
|
||||
|
@ -229,8 +229,7 @@ namespace ASC.Web.Core
|
||||
|
||||
public Guid GetParentItemID(Guid itemID)
|
||||
{
|
||||
var m = this[itemID] as IModule;
|
||||
return m != null ? m.ProjectId : Guid.Empty;
|
||||
return this[itemID] is IModule m ? m.ProjectId : Guid.Empty;
|
||||
}
|
||||
|
||||
public static int GetSortOrder(IWebItem item)
|
||||
|
@ -370,11 +370,9 @@ namespace ASC.Web.Core
|
||||
|
||||
public ISecurityObjectId InheritFrom(ISecurityObjectId objectId)
|
||||
{
|
||||
var s = objectId as WebItemSecurityObject;
|
||||
if (s != null)
|
||||
if (objectId is WebItemSecurityObject s)
|
||||
{
|
||||
var parent = WebItemSecurityObject.Create(WebItemManager.Instance.GetParentItemID(s.WebItemId).ToString("N")) as WebItemSecurityObject;
|
||||
return parent != null && parent.WebItemId != s.WebItemId && parent.WebItemId != Guid.Empty ? parent : null;
|
||||
return WebItemSecurityObject.Create(WebItemManager.Instance.GetParentItemID(s.WebItemId).ToString("N")) is WebItemSecurityObject parent && parent.WebItemId != s.WebItemId && parent.WebItemId != Guid.Empty ? parent : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -76,9 +76,7 @@ namespace ASC.Web.Core.WhiteLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
var defaultSettings = GetDefault() as AdditionalWhiteLabelSettings;
|
||||
|
||||
if (defaultSettings == null) return false;
|
||||
if (!(GetDefault() is AdditionalWhiteLabelSettings defaultSettings)) return false;
|
||||
|
||||
return StartDocsEnabled == defaultSettings.StartDocsEnabled &&
|
||||
HelpCenterEnabled == defaultSettings.HelpCenterEnabled &&
|
||||
|
@ -58,9 +58,7 @@ namespace ASC.Web.Core.WhiteLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
var defaultSettings = GetDefault() as CompanyWhiteLabelSettings;
|
||||
|
||||
if (defaultSettings == null) return false;
|
||||
if (!(GetDefault() is CompanyWhiteLabelSettings defaultSettings)) return false;
|
||||
|
||||
return CompanyName == defaultSettings.CompanyName &&
|
||||
Site == defaultSettings.Site &&
|
||||
|
@ -61,9 +61,7 @@ namespace ASC.Web.Core.WhiteLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
var defaultSettings = GetDefault() as MailWhiteLabelSettings;
|
||||
|
||||
if (defaultSettings == null) return false;
|
||||
if (!(GetDefault() is MailWhiteLabelSettings defaultSettings)) return false;
|
||||
|
||||
return FooterEnabled == defaultSettings.FooterEnabled &&
|
||||
FooterSocialEnabled == defaultSettings.FooterSocialEnabled &&
|
||||
|
Loading…
Reference in New Issue
Block a user