Ejemplo n.º 1
0
        internal RuleCache <T> GetRuleCache <T>() where T : class
        {
            // make sure we have cache.
            if (Cache == null)
            {
                Interlocked.CompareExchange(ref Cache, new Dictionary <Type, object>(), null);
            }

            object ruleCache;
            var    cache = Cache;

            lock (cache) {
                if (!cache.TryGetValue(typeof(T), out ruleCache))
                {
                    cache[typeof(T)] = ruleCache = new RuleCache <T>();
                }
            }

            RuleCache <T> result = ruleCache as RuleCache <T>;

            Debug.Assert(result != null);
            return(result);
        }
Ejemplo n.º 2
0
 public static T[] GetCachedRules <T>(RuleCache <T> cache) where T : class
 {
     return(cache.GetRules());
 }