public ForCacheManagerNamedBuilder(ICachingConfiguration context, string cacheManagerName)
                : base(context)
            {
                cacheManagerData = new CacheManagerData
                {
                    Name = cacheManagerName
                };

                base.CachingSettings.CacheManagers.Add(cacheManagerData);
            }
 /// <summary>
 /// Add a new <see cref="CacheManagerData"/> to the collection.
 /// </summary>
 /// <param name="data">Distribution strategy to add.</param>
 public void Add(CacheManagerData data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("cacheManager");
     }
     if (data.Name == null)
     {
         throw new InvalidOperationException(SR.ExceptionNullCacheManagerDataName);
     }
     base.AddProvider(data);
 }
 /// <summary>
 /// Add a new <see cref="CacheManagerData"/> to the collection.
 /// </summary>
 /// <param name="data">Distribution strategy to add.</param>
 public void Add(CacheManagerData data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("cacheManager");
     }
     if (data.Name == null)
     {
         throw new InvalidOperationException(SR.ExceptionNullCacheManagerDataName);
     }
     base.AddProvider(data);
 }
        public void Setup()
        {
            CacheStorageData cacheStorageData = new CacheStorageData("Null Storage", typeof(NullBackingStore));
            CacheManagerData cacheManagerData = new CacheManagerData("Default Cache Manager", 10, 10, 10, cacheStorageData.Name);
            
            CacheManagerSettings settings = new CacheManagerSettings();
            settings.CacheManagers.Add(cacheManagerData);
            settings.BackingStores.Add(cacheStorageData);

            settings.DefaultCacheManager = cacheManagerData.Name;

            registrations = settings.GetRegistrations(null);
        }
 public System.Configuration.ConfigurationSection GetSection(string sectionName)
 {
     if (sectionName.Equals("cachingConfiguration", StringComparison.CurrentCulture))
     {
         CacheManagerSettings settings = new CacheManagerSettings();
         settings.DefaultCacheManager = "Default Cache Manager";
         CacheManagerData data = new CacheManagerData("Default Cache Manager", 60, 1000, 10, "inMemory");
         settings.CacheManagers.Add(data);
         CacheStorageData storageData = new CacheStorageData("inMemory", typeof(NullBackingStore));
         settings.BackingStores.Add(storageData);
         return settings;
     }
     return null;
 }
Example #6
0
        public ICacheManager Assemble(IBuilderContext context, CacheManagerDataBase objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            CacheManagerData cacheManagerData = (CacheManagerData)objectConfiguration;
            IBackingStore    backingStore
                = BackingStoreCustomFactory.Instance.Create(context, cacheManagerData.CacheStorage, configurationSource, reflectionCache);
            CachingInstrumentationProvider instrumentationProvider = CreateInstrumentationProvider(cacheManagerData.Name, configurationSource, reflectionCache);
            CacheManager createdObject
                = new CacheManagerFactoryHelper().BuildCacheManager(
                      cacheManagerData.Name,
                      backingStore,
                      cacheManagerData.MaximumElementsInCacheBeforeScavenging,
                      cacheManagerData.NumberToRemoveWhenScavenging,
                      cacheManagerData.ExpirationPollFrequencyInSeconds,
                      instrumentationProvider);

            return(createdObject);
        }
        public void Setup()
        {
            configurationSource = new ConfigurationSourceUpdatable();
            cacheSettings = new CacheManagerSettings();

            configurationSource.Add(CacheManagerSettings.SectionName, cacheSettings);

            cacheStorageData = new CacheStorageData("Null Storage", typeof(NullBackingStore));
            cacheManagerData = new CacheManagerData("Default Cache Manager", 10, 10, 10, cacheStorageData.Name);
            
            CacheManagerSettings settings = new CacheManagerSettings();
            cacheSettings.CacheManagers.Add(cacheManagerData);
            cacheSettings.BackingStores.Add(cacheStorageData);
            cacheSettings.DefaultCacheManager = cacheManagerData.Name;

            UnityContainer container = new UnityContainer();
            configurator = new UnityContainerConfigurator(container);
            serviceLcoator = new UnityServiceLocator(container);
            EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource);
        }
        public void CanResolveDataBackingStoreWithOutEncryptionProvider()
        {
            const string key = "fooKey";
            DataCacheStorageData data = new DataCacheStorageData("Data Cache Storage", "CachingDatabase", "fooPartition");
            settings.BackingStores.Add(data);

            CacheManagerData managerData = new CacheManagerData("defaultCacheManager", 300, 200, 100, "Data Cache Storage");
            settings.CacheManagers.Add(managerData);
            settings.DefaultCacheManager = "defaultCacheManager";

            dbSettings.DefaultDatabase = "CachingDatabase";

            container = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource);
            DataBackingStore createdStore = container.GetInstance<DataBackingStore>("Data Cache Storage");

            Assert.IsNotNull(createdStore);
            createdStore.Add(new CacheItem(key, 1, CacheItemPriority.Low, null, null));
            Assert.AreEqual(1, createdStore.Count);
            createdStore.Remove(key);
            Assert.AreEqual(0, createdStore.Count);
        }
 /// <summary>
 /// Copies the elements of the <see cref="CacheManagerDataCollection"/>
 /// </summary>
 /// <param name="array">The one-dimensional Array that is the destination of the elements copied from <see cref="CacheManagerDataCollection"/>.</param>
 /// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins. </param>
 public void CopyTo(CacheManagerData[] array, int index)
 {
     base.CopyTo((Array)array, index);
 }
        public void Setup()
        {
            CustomCacheStorageData customStorageData = new CustomCacheStorageData("Custom Storage", typeof(MockCustomStorageBackingStore));
            CacheManagerData cacheManagerData = new CacheManagerData("Default Cache Manager", 10, 10, 10, customStorageData.Name);

            CacheManagerSettings settings = new CacheManagerSettings();
            settings.CacheManagers.Add(cacheManagerData);
            settings.BackingStores.Add(customStorageData);

            registrations = settings.GetRegistrations(null);
        }
        public void Setup()
        {
            IsolatedStorageCacheStorageData isolatedStorageData = new IsolatedStorageCacheStorageData("Isolated Storage", string.Empty, "part");
            CacheManagerData cacheManagerData = new CacheManagerData("Default Cache Manager", 10, 10, 10, isolatedStorageData.Name);

            CacheManagerSettings settings = new CacheManagerSettings();
            settings.CacheManagers.Add(cacheManagerData);
            settings.BackingStores.Add(isolatedStorageData);

            registrations = settings.GetRegistrations(null);
        }
        public void CacheManagerIsSingleton()
        {
            CacheStorageData data = new CacheStorageData("storage", typeof(NullBackingStore));
            settings.BackingStores.Add(data);

            CacheManagerData managerData = new CacheManagerData("name", 300, 200, 100, "storage");
            settings.CacheManagers.Add(managerData);

            IServiceLocator container = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource);

            CacheManager createdObject1 = (CacheManager)container.GetInstance<ICacheManager>("name");
            CacheManager createdObject2 = (CacheManager)container.GetInstance<ICacheManager>("name");

            Assert.IsNotNull(createdObject1);
            Assert.AreSame(createdObject1, createdObject2);
        }
        public void CanCreateCacheManager()
        {
            CacheStorageData data = new CacheStorageData("storage", typeof(NullBackingStore));
            settings.BackingStores.Add(data);

            CacheManagerData managerData = new CacheManagerData("name", 300, 200, 100, "storage");
            settings.CacheManagers.Add(managerData);

            IServiceLocator container = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource);

            CacheManager createdObject = (CacheManager)container.GetInstance<ICacheManager>("name");

            Assert.IsNotNull(createdObject);

            // does it work?
            object value = new object();
            createdObject.Add("key", value);
            Assert.AreSame(value, createdObject.GetData("key"));
        }