예제 #1
0
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="CacheManagerData"/> described by the <see cref="CacheManagerSettings"/> configuration section.
        /// </summary>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="name">The name of the instance to build. It is part of the <see cref="ICustomFactory.CreateObject(IBuilderContext, string, IConfigurationSource, ConfigurationReflectionCache)"/> method, but it is not used in this implementation.</param>
        /// <param name="configurationSource">The source for configuration objects.</param>
        /// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
        /// <returns>A fully initialized instance of <see cref="CacheManager"/>.</returns>
        public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            CacheManagerData objectConfiguration = GetConfiguration(name, configurationSource);

            IBackingStore backingStore
                = BackingStoreCustomFactory.Instance.Create(context, objectConfiguration.CacheStorage, configurationSource, reflectionCache);

            CachingInstrumentationProvider instrumentationProvider = CreateInstrumentationProvider(objectConfiguration.Name, configurationSource, reflectionCache);

            CacheManager createdObject
                = new CacheManagerFactoryHelper().BuildCacheManager(
                    objectConfiguration.Name,
                    backingStore,
                    objectConfiguration.MaximumElementsInCacheBeforeScavenging,
                    objectConfiguration.NumberToRemoveWhenScavenging,
                    objectConfiguration.ExpirationPollFrequencyInSeconds,
                    instrumentationProvider);

            RegisterObject(context, name, createdObject);

            return createdObject;
        }
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="CacheManagerData"/> described by the <see cref="CacheManagerSettings"/> configuration section.
        /// </summary>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="name">The name of the instance to build. It is part of the <see cref="ICustomFactory.CreateObject(IBuilderContext, string, IConfigurationSource, ConfigurationReflectionCache)"/> method, but it is not used in this implementation.</param>
        /// <param name="configurationSource">The source for configuration objects.</param>
        /// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
        /// <returns>A fully initialized instance of <see cref="CacheManager"/>.</returns>
        public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            CacheManagerData objectConfiguration = GetConfiguration(name, configurationSource);

            IBackingStore backingStore
                = BackingStoreCustomFactory.Instance.Create(context, objectConfiguration.CacheStorage, configurationSource, reflectionCache);

            CachingInstrumentationProvider instrumentationProvider = CreateInstrumentationProvider(objectConfiguration.Name, configurationSource, reflectionCache);

            CacheManager createdObject
                = new CacheManagerFactoryHelper().BuildCacheManager(
                      objectConfiguration.Name,
                      backingStore,
                      objectConfiguration.MaximumElementsInCacheBeforeScavenging,
                      objectConfiguration.NumberToRemoveWhenScavenging,
                      objectConfiguration.ExpirationPollFrequencyInSeconds,
                      instrumentationProvider);

            RegisterObject(context, name, createdObject);

            return(createdObject);
        }