コード例 #1
0
        /// <summary>
        /// Returns EntityType object from cache.  If entityType does not already exist in cache, it
        /// will be read and added to cache
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static EntityTypeCache Read(int id)
        {
            string cacheKey = EntityTypeCache.CacheKey(id);

            ObjectCache     cache      = MemoryCache.Default;
            EntityTypeCache entityType = cache[cacheKey] as EntityTypeCache;

            if (entityType != null)
            {
                return(entityType);
            }
            else
            {
                Rock.Model.EntityTypeService entityTypeService = new Rock.Model.EntityTypeService();
                Rock.Model.EntityType        entityTypeModel   = entityTypeService.Get(id);
                if (entityTypeModel != null)
                {
                    entityType = CopyModel(entityTypeModel);

                    cache.Set(cacheKey, entityType, new CacheItemPolicy());

                    return(entityType);
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Reads the specified name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static EntityTypeCache Read(string name)
        {
            if (entityTypes.ContainsKey(name))
            {
                return(Read(entityTypes[name]));
            }

            var entityTypeService = new Rock.Model.EntityTypeService();
            var entityTypeModel   = entityTypeService.Get(name, true, null);

            return(Read(entityTypeModel));
        }
コード例 #3
0
ファイル: EntityTypeCache.cs プロジェクト: jh2mhs8/Rock-ChMS
        /// <summary>
        /// Reads the specified name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static EntityTypeCache Read( string name )
        {
            if ( entityTypes.ContainsKey( name ) )
                return Read( entityTypes[name] );

            var entityTypeService = new Rock.Model.EntityTypeService();
            var entityTypeModel = entityTypeService.Get( name, true, null );
            return Read( entityTypeModel );
        }
コード例 #4
0
ファイル: EntityTypeCache.cs プロジェクト: jh2mhs8/Rock-ChMS
        /// <summary>
        /// Returns EntityType object from cache.  If entityType does not already exist in cache, it
        /// will be read and added to cache
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static EntityTypeCache Read( int id )
        {
            string cacheKey = EntityTypeCache.CacheKey( id );

            ObjectCache cache = MemoryCache.Default;
            EntityTypeCache entityType = cache[cacheKey] as EntityTypeCache;

            if ( entityType != null )
                return entityType;
            else
            {
                Rock.Model.EntityTypeService entityTypeService = new Rock.Model.EntityTypeService();
                Rock.Model.EntityType entityTypeModel = entityTypeService.Get( id );
                if ( entityTypeModel != null )
                {
                    entityType = CopyModel( entityTypeModel );

                    cache.Set( cacheKey, entityType, new CacheItemPolicy() );

                    return entityType;
                }
                else
                    return null;
            }
        }