Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 5
0
        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(); }));
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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
        }