Example #1
0
        /// <summary>
        /// Cache the supplied list of Dwarfs
        /// </summary>
        internal static GemList <T> SetCacheList <T>(string key, GemList <T> list) where T : Gem <T>, new()
        {
            if (Cache == null)
            {
                return(list);
            }

            Insert(key, list, AggregateCacheDependencies <T>());

            return(list);
        }
Example #2
0
        /// <summary>
        /// Helper method for handling GemLists
        /// </summary>
        protected GemList <TY> Gems <TY>(Expression <Func <T, DwarfList <TY> > > property) where TY : Gem <TY>, new()
        {
            var propertyName = ReflectionHelper.GetPropertyName(property);
            var key          = GetCollectionKey(propertyName);

            var cacheItem = CacheManager.Cache[key] as GemList <TY>;

            if (cacheItem != null)
            {
                return(cacheItem);
            }

            if (originalValues == null || !originalValues.ContainsKey(propertyName) || originalValues[propertyName] == null)
            {
                return(CacheManager.SetCacheList(key, new GemList <TY>(x => x.Id)));
            }

            return(CacheManager.SetCacheList(key, new GemList <TY>(GemList <TY> .ParseValue(originalValues[propertyName].ToString()), x => x.Id)));
        }