Esempio n. 1
0
        private static BlockCache CopyModel(Rock.Model.Block blockModel)
        {
            BlockCache block = new BlockCache(blockModel);

            block.AttributeValues = blockModel.AttributeValues;

            block.AttributeIds = new List <int>();
            if (blockModel.Attributes != null)
            {
                foreach (var attribute in blockModel.Attributes)
                {
                    block.AttributeIds.Add(attribute.Value.Id);
                }
            }

            return(block);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds Block model to cache, and returns cached object
        /// </summary>
        /// <param name="blockModel"></param>
        /// <returns></returns>
        public static BlockCache Read(Rock.Model.Block blockModel)
        {
            string cacheKey = BlockCache.CacheKey(blockModel.Id);

            ObjectCache cache = MemoryCache.Default;
            BlockCache  block = cache[cacheKey] as BlockCache;

            if (block != null)
            {
                return(block);
            }
            else
            {
                block = BlockCache.CopyModel(blockModel);
                cache.Set(cacheKey, block, new CacheItemPolicy());

                return(block);
            }
        }
Esempio n. 3
0
 private BlockCache(Rock.Model.Block model) : base(model)
 {
 }