Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 3
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 );
        }
Ejemplo n.º 4
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;
            }
        }