internal static BusinessRuleManager GetRulesForType(Type type, string ruleSet) { if (ruleSet == ApplicationContext.DefaultRuleSet) { ruleSet = null; } BusinessRuleManager result = null; var key = new RuleSetKey { Type = type, RuleSet = ruleSet }; var found = false; try { found = _perTypeRules.TryGetValue(key, out result); } catch { /* failure will drop into !found block */ } if (!found) { lock (_perTypeRules) { if (!_perTypeRules.TryGetValue(key, out result)) { result = new BusinessRuleManager(); _perTypeRules.Add(key, result); } } } return(result); }
internal static AuthorizationRuleManager GetRulesForType(ApplicationContext applicationContext, Type type, string ruleSet) { if (ruleSet == ApplicationContext.DefaultRuleSet) { ruleSet = null; } var key = new RuleSetKey { Type = type, RuleSet = ruleSet }; #if NET5_0_OR_GREATER var rulesInfo = _perTypeRules.Value .GetOrAdd( key, (t) => AssemblyLoadContextManager.CreateCacheInstance(type, new AuthorizationRuleManager(), OnAssemblyLoadContextUnload) ); var result = rulesInfo.Item2; #else var result = _perTypeRules.Value.GetOrAdd(key, (t) => { return(new AuthorizationRuleManager()); }); #endif InitializePerTypeRules(applicationContext, result, type); return(result); }
internal static AuthorizationRuleManager GetRulesForType(Type type, string ruleSet) { // use null if RuleSet is "default" if (ruleSet == ApplicationContext.DefaultRuleSet) { ruleSet = null; } AuthorizationRuleManager result = null; var key = new RuleSetKey { Type = type, RuleSet = ruleSet }; if (!_perTypeRules.TryGetValue(key, out result)) { lock (_perTypeRules) { if (!_perTypeRules.TryGetValue(key, out result)) { result = new AuthorizationRuleManager(); _perTypeRules.Add(key, result); } } } InitializePerTypeRules(result, type); return(result); }
internal static BusinessRuleManager GetRulesForType(Type type, string ruleSet) { if (ruleSet == ApplicationContext.DefaultRuleSet) { ruleSet = null; } BusinessRuleManager result = null; var key = new RuleSetKey { Type = type, RuleSet = ruleSet }; if (!_perTypeRules.TryGetValue(key, out result)) { lock (_perTypeRules) { if (!_perTypeRules.TryGetValue(key, out result)) { result = new BusinessRuleManager(); _perTypeRules.Add(key, result); } } } return(result); }
internal static BusinessRuleManager GetRulesForType(Type type, string ruleSet) { if (ruleSet == ApplicationContext.DefaultRuleSet) { ruleSet = null; } var key = new RuleSetKey { Type = type, RuleSet = ruleSet }; return(_perTypeRules.Value.GetOrAdd(key, (t) => { return new BusinessRuleManager(); })); }
internal static AuthorizationRuleManager GetRulesForType(Type type, string ruleSet) { if (ruleSet == ApplicationContext.DefaultRuleSet) { ruleSet = null; } var key = new RuleSetKey { Type = type, RuleSet = ruleSet }; var result = _perTypeRules.Value.GetOrAdd(key, (t) => { return(new AuthorizationRuleManager()); }); InitializePerTypeRules(result, type); return(result); }
internal static BusinessRuleManager GetRulesForType(Type type, string ruleSet) { if (ruleSet == ApplicationContext.DefaultRuleSet) { ruleSet = null; } var key = new RuleSetKey { Type = type, RuleSet = ruleSet }; #if NET5_0_OR_GREATER var rulesInfo = _perTypeRules.Value .GetOrAdd( key, (t) => AssemblyLoadContextManager.CreateCacheInstance(type, new BusinessRuleManager(), OnAssemblyLoadContextUnload) ); return(rulesInfo.Item2); #else return(_perTypeRules.Value.GetOrAdd(key, (t) => { return new BusinessRuleManager(); })); #endif }