private void InitializeCacheManager() { if (null == _cacheManager) { var fileSource = new FileConfigurationSource("SUT.PrintEngine.App.config"); var factory = new CacheManagerFactory(fileSource); _cacheManager = factory.CreateDefault(); } }
public void WillThrowExceptionIfCannotDefault() { DictionaryConfigurationSource source = new DictionaryConfigurationSource(); source.Add(CacheManagerSettings.SectionName, new CacheManagerSettings()); CacheManagerFactory factory2 = new CacheManagerFactory(source); factory2.CreateDefault(); Assert.Fail("Should have thrown ConfigurationErrorsException"); }
public CacheBase() { if (cacheManager == null) { DictionaryConfigurationSource internalConfigurationSource = new DictionaryConfigurationSource(); CacheManagerSettings settings = new CacheManagerSettings(); internalConfigurationSource.Add(CacheManagerSettings.SectionName, settings); CacheStorageData storageConfig = new CacheStorageData("Null Storage", typeof(NullBackingStore)); settings.BackingStores.Add(storageConfig); CacheManagerData cacheManagerConfig = new CacheManagerData("CustomCache", 60, 1000, 10, storageConfig.Name); settings.CacheManagers.Add(cacheManagerConfig); settings.DefaultCacheManager = cacheManagerConfig.Name; CacheManagerFactory cacheFactory = new CacheManagerFactory(internalConfigurationSource); cacheManager = cacheFactory.CreateDefault(); } }
public static ICacheManager Create(string configSource, string cacheName) { ICacheManager cache; FileConfigurationSource config = new FileConfigurationSource(configSource); CacheManagerFactory cf = new CacheManagerFactory(config); if (string.IsNullOrEmpty(cacheName)) { cache = cf.Create(cacheName); } else { cache = cf.CreateDefault(); } return(cache); }
public void CanCreateDefaultCacheManager() { CacheManager cacheManager = factory.CreateDefault(); Assert.IsNotNull(cacheManager); }