private static BlockInstance CopyModel( Rock.CMS.BlockInstance blockInstanceModel ) { BlockInstance blockInstance = new BlockInstance(); blockInstance.Id = blockInstanceModel.Id; blockInstance.BlockId = blockInstanceModel.BlockId; blockInstance.Name = blockInstanceModel.Name; blockInstance.Zone = blockInstanceModel.Zone; blockInstance.BlockInstanceLocation = blockInstanceModel.Page != null ? BlockInstanceLocation.Page : BlockInstanceLocation.Layout; blockInstance.Order = blockInstanceModel.Order; blockInstance.OutputCacheDuration = blockInstanceModel.OutputCacheDuration; blockInstance.AttributeValues = blockInstanceModel.AttributeValues; blockInstance.AttributeIds = new List<int>(); if (blockInstanceModel.Attributes != null) foreach ( var category in blockInstanceModel.Attributes ) foreach ( var attribute in category.Value ) blockInstance.AttributeIds.Add( attribute.Id ); blockInstance.AuthEntity = blockInstanceModel.AuthEntity; blockInstance.InstanceActions = blockInstanceModel.SupportedActions; return blockInstance; }
/// <summary> /// Removes blockInstance from cache /// </summary> /// <param name="id"></param> public static void Flush(int id) { ObjectCache cache = MemoryCache.Default; cache.Remove(BlockInstance.CacheKey(id)); }