public void SetUp()
 {
     provider            = new CacheStorageDataManageabilityProvider();
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     configurationObject = new CacheStorageData();
 }
 public void SetUp()
 {
     provider = new CacheStorageDataManageabilityProvider();
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     configurationObject = new CacheStorageData();
 }
        private void NullEncryptorTests(string instanceName)
        {
            MockStorageEncryptionProvider.Encrypted = false;
            MockStorageEncryptionProvider.Decrypted = false;

            CacheManagerSettings          settings               = (CacheManagerSettings)TestConfigurationSource.GenerateConfiguration().GetSection(CacheManagerSettings.SectionName);
            CacheStorageData              cacheStorageData       = settings.BackingStores.Get(settings.CacheManagers.Get(instanceName).CacheStorage);
            StorageEncryptionProviderData encryptionProviderData = settings.EncryptionProviders.Get(cacheStorageData.StorageEncryption);

            IStorageEncryptionProvider provider =
                EnterpriseLibraryFactory.BuildUp <IStorageEncryptionProvider>(encryptionProviderData.Name, TestConfigurationSource.GenerateConfiguration());

            Assert.IsNotNull(provider);

            byte[] input     = new byte[] { 0, 1, 2, 3, 4, 5 };
            byte[] encrypted = provider.Encrypt(input);

            Assert.IsTrue(MockStorageEncryptionProvider.Encrypted, "static encrypted");

            Assert.IsTrue(CompareBytes(input, encrypted), "no encryption performed");

            byte[] decrypted = provider.Decrypt(encrypted);
            Assert.IsTrue(MockStorageEncryptionProvider.Decrypted, "static decrypted");

            Assert.IsTrue(CompareBytes(encrypted, decrypted), "no decryption performed");
            Assert.IsTrue(CompareBytes(input, decrypted), "no decryption performed2");
        }
        private void CreateStorageNode(CacheManagerNode cacheManagerNode, string cacheStorageName)
        {
            if (string.IsNullOrEmpty(cacheStorageName))
            {
                return;
            }

            CacheStorageData cacheStorageData = cacheManagerSettings.BackingStores.Get(cacheStorageName);

            if (null == cacheStorageData)
            {
                LogError(cacheManagerNode, string.Format(CultureInfo.CurrentUICulture, Resources.ExceptionNoStorageProviderDefined, cacheStorageName));
                return;
            }
            if (cacheStorageData.Type == typeof(NullBackingStore))
            {
                return;                                                                // special case
            }
            ConfigurationNode storageNode = NodeCreationService.CreateNodeByDataType(cacheStorageData.GetType(), new object[] { cacheStorageData });

            if (null == storageNode)
            {
                LogNodeMapError(cacheManagerNode, cacheStorageData.GetType());
                return;
            }
            cacheManagerNode.AddNode(storageNode);
            CreateEncryptionNode(storageNode, cacheStorageData.StorageEncryption);
        }
        public void Setup()
        {
            CacheStorageData storeData = new CacheStorageData("cache store", typeof(BackingStoreWithoutDefaultCtor));

            settings = new CacheManagerSettings();
            settings.BackingStores.Add(storeData);
        }
Пример #6
0
        /// <summary>
        /// <para>Initialize the <see cref="IConfigurationProvider"/> by invoking the <see cref="IConfigurationProvider.Initialize"/> method.</para>
        /// </summary>
        /// <param name="cacheManagerName">
        /// <para>The name of the <see cref="CacheManager"/>.</para>
        /// </param>
        /// <param name="provider">
        /// <para>The <see cref="IConfigurationProvider"/> to initialize.</para>
        /// </param>
        protected override void InitializeConfigurationProvider(string cacheManagerName, IConfigurationProvider provider)
        {
            CacheStorageData cacheStorageData = GetCacheStorageData(cacheManagerName);

            provider.ConfigurationName = cacheStorageData.Name;
            ((IBackingStore)provider).CurrentCacheManager = cacheManagerName;
            base.InitializeConfigurationProvider(cacheManagerName, provider);
        }
Пример #7
0
 /// <summary>
 /// Creates node with sepecifed display name and configuration data.
 /// </summary>
 /// <param name="cacheStorageData">The configuration data.</param>
 protected CacheStorageNode(CacheStorageData cacheStorageData) : base()
 {
     if (cacheStorageData == null)
     {
         throw new ArgumentNullException("cacheStorageData");
     }
     this.cacheStorageData = cacheStorageData;
 }
Пример #8
0
 public void SetUp()
 {
     provider            = new ConfigurationElementManageabilityProviderWrapper(new CacheStorageDataManageabilityProvider());
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     wmiSettings         = new List <ConfigurationSetting>();
     configurationObject = new CacheStorageData();
 }
Пример #9
0
 /// <summary>
 /// Creates node with sepecifed display name and configuration data.
 /// </summary>
 /// <param name="cacheStorageData">The configuration data.</param>
 protected CacheStorageNode(CacheStorageData cacheStorageData)
     : base()
 {
     if (cacheStorageData == null)
     {
         throw new ArgumentNullException("cacheStorageData");
     }
     this.cacheStorageData = cacheStorageData;
 }
Пример #10
0
        public void CanReadCacheStorageObject()
        {
            XmlTextReader    xmlReader               = new XmlTextReader(new StringReader(configurationSection));
            XmlSerializer    xmlSerializer           = new XmlSerializer(typeof(CacheStorageData));
            CacheStorageData objectFromConfiguration = xmlSerializer.Deserialize(xmlReader) as CacheStorageData;

            Assert.AreEqual("inIsolatedStorage", objectFromConfiguration.Name);
            Assert.IsNotNull(objectFromConfiguration.TypeName);
            Assert.IsNotNull(Type.GetType(objectFromConfiguration.TypeName));
            Assert.IsTrue(typeof(IBackingStore).IsAssignableFrom(Type.GetType(objectFromConfiguration.TypeName)));
        }
Пример #11
0
        /// <summary>
        /// <para>Gets the <see cref="CacheStorageData"/> from configuration for the named <see cref="CacheManager"/></para>
        /// </summary>
        /// <param name="cacheManagerName">
        /// <para>The name of the <see cref="CacheManager"/>.</para>
        /// </param>
        /// <returns>
        /// <para>A <see cref="CacheStorageData"/> object.</para>
        /// </returns>
        public virtual CacheStorageData GetCacheStorageDataForCacheManager(string cacheManagerName)
        {
            CacheManagerData cacheManagerData = GetCacheManagerData(cacheManagerName);
            CacheStorageData cacheStorageData = cacheManagerData.CacheStorage;

            if (cacheStorageData == null)
            {
                throw new ConfigurationException(SR.CannotInstantiateCacheStorage(cacheManagerName));
            }
            return(cacheStorageData);
        }
Пример #12
0
        private void BuildCacheStorageProviders()
        {
            foreach (CacheStorageNode cacheStorageNode in hierarchy.FindNodesByType(cacheSettingsNode, typeof(CacheStorageNode)))
            {
                CacheStorageData           cacheStorageData         = cacheStorageNode.CacheStorageData;
                CacheStorageEncryptionNode encryptionNodeForStorage = (CacheStorageEncryptionNode)hierarchy.FindNodeByType(cacheStorageNode, typeof(CacheStorageEncryptionNode));
                cacheStorageData.StorageEncryption = (encryptionNodeForStorage == null) ? string.Empty : encryptionNodeForStorage.Name;

                cacheConfiguration.BackingStores.Add(cacheStorageData);
            }
        }
Пример #13
0
            public ICachingConfiguration StoreInMemory()
            {
                var nullBackingStore = CachingSettings.BackingStores.Where(x => x.Type == typeof(NullBackingStore)).FirstOrDefault();

                if (nullBackingStore == null)
                {
                    nullBackingStore = new CacheStorageData("Null Backing Store", typeof(NullBackingStore));
                    CachingSettings.BackingStores.Add(nullBackingStore);
                }

                return(StoreInSharedBackingStore(nullBackingStore.Name));
            }
        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);
        }
Пример #15
0
 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();
     }
 }
Пример #16
0
        public void RegisteredCacheStorageDataProviderIsCalledWithCorrectOverrides()
        {
            MockConfigurationElementManageabilityProvider registeredProvider
                = new MockConfigurationElementManageabilityProvider();
            Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders
                = new Dictionary <Type, ConfigurationElementManageabilityProvider>();

            subProviders.Add(typeof(CacheStorageData), registeredProvider);
            provider = new ConfigurationSectionManageabilityProviderWrapper(
                new CacheManagerSettingsManageabilityProvider(subProviders));

            CacheStorageData data = new CacheStorageData("store1", typeof(NullBackingStore));

            section.BackingStores.Add(data);

            MockRegistryKey machineStoresKey = new MockRegistryKey(false);

            machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.BackingStoresKeyName, machineStoresKey);
            MockRegistryKey machineStoreKey = new MockRegistryKey(false);

            machineStoresKey.AddSubKey("store1", machineStoreKey);
            MockRegistryKey machineOtherStoreKey = new MockRegistryKey(false);

            machineStoresKey.AddSubKey("store2", machineOtherStoreKey);

            MockRegistryKey userStoresKey = new MockRegistryKey(false);

            userKey.AddSubKey(CacheManagerSettingsManageabilityProvider.BackingStoresKeyName, userStoresKey);
            MockRegistryKey userStoreKey = new MockRegistryKey(false);

            userStoresKey.AddSubKey("store1", userStoreKey);
            MockRegistryKey userOtherStoreKey = new MockRegistryKey(false);

            userStoresKey.AddSubKey("store2", userOtherStoreKey);

            provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings);

            Assert.IsTrue(registeredProvider.called);
            Assert.AreSame(data, registeredProvider.LastConfigurationObject);
            Assert.AreEqual(machineStoreKey, registeredProvider.machineKey);
            Assert.AreEqual(userStoreKey, registeredProvider.userKey);

            Assert.IsTrue(
                MockRegistryKey.CheckAllClosed(machineStoresKey, machineStoreKey, machineOtherStoreKey,
                                               userStoresKey, userStoreKey, userOtherStoreKey));
        }
Пример #17
0
        private ICacheManager CreateEntLibCacheManager()
        {
            var internalConfigurationSource = new DictionaryConfigurationSource();
            var settings = new CacheManagerSettings();

            internalConfigurationSource.Add(CacheManagerSettings.SectionName, settings);

            var storageConfig = new CacheStorageData("Null Storage", typeof(NullBackingStore));

            settings.BackingStores.Add(storageConfig);

            var cacheManagerConfig = new CacheManagerData("CustomCache", 60, 1000, 10, storageConfig.Name);

            settings.CacheManagers.Add(cacheManagerConfig);
            settings.DefaultCacheManager = cacheManagerConfig.Name;

            return(new CacheManagerFactory(internalConfigurationSource).CreateDefault());
        }
        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);
        }
Пример #19
0
        private DictionaryConfigurationSource GetConfigurationSource()
        {
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();

            CacheManagerSettings cachingConfiguration = new CacheManagerSettings();

            cachingConfiguration.DefaultCacheManager = Group;

            Type             nullBackingStoreType = Type.GetType(new NullBackingStore().GetType().AssemblyQualifiedName);
            CacheStorageData cacheStorageData     = new CacheStorageData("CACHE", nullBackingStoreType);

            cachingConfiguration.BackingStores.Add(cacheStorageData);


            CacheManagerData cacheManagerData = new CacheManagerData(Group, ExpirationSeconds, 10000, 5000, "CACHE");

            cachingConfiguration.CacheManagers.Add(cacheManagerData);

            configurationSource.Add(CacheManagerSettings.SectionName, cachingConfiguration);
            return(configurationSource);
        }
Пример #20
0
        public void RegisteredCacheStorageDataProviderIsCalledWithNoOverrides()
        {
            MockConfigurationElementManageabilityProvider registeredProvider
                = new MockConfigurationElementManageabilityProvider();
            Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders
                = new Dictionary <Type, ConfigurationElementManageabilityProvider>();

            subProviders.Add(typeof(CacheStorageData), registeredProvider);
            provider = new CacheManagerSettingsManageabilityProvider(subProviders);

            CacheStorageData data = new CacheStorageData("store1", typeof(NullBackingStore));

            section.BackingStores.Add(data);

            provider.OverrideWithGroupPolicies(section, true, machineKey, userKey);

            Assert.IsTrue(registeredProvider.called);
            Assert.AreSame(data, registeredProvider.LastConfigurationObject);
            Assert.AreEqual(null, registeredProvider.machineKey);
            Assert.AreEqual(null, registeredProvider.userKey);
        }
        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"));
        }
Пример #22
0
        internal DictionaryConfigurationSource GetCachingConfiguration(string policyName)
        {
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();

            CacheManagerSettings cachingConfiguration = new CacheManagerSettings();

            cachingConfiguration.DefaultCacheManager = policyName;

            Type             nullBackingStoreType = Type.GetType(new NullBackingStore().GetType().AssemblyQualifiedName);
            CacheStorageData cacheStorageData     = new CacheStorageData("MyCACHE", nullBackingStoreType);

            cachingConfiguration.BackingStores.Add(cacheStorageData);

            LocalCachePolicy policy = cacheSettingManager.GetLocalCachePolicy(policyName);

            CacheManagerData cacheManagerData = new CacheManagerData(policyName, policy.ExpiredSeconds, policy.MaxElements, 10, "MyCACHE");

            cachingConfiguration.CacheManagers.Add(cacheManagerData);

            configurationSource.Add(CacheManagerSettings.SectionName, cachingConfiguration);
            return(configurationSource);
        }
Пример #23
0
        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);
        }
        /// <devdoc>
        /// ADM templates for caching are different from the other blocks' templates to match the configuration console's
        /// user experience. Instead of having separate categories with policies for cache managers, backing stores and
        /// encryption providers, the policy for a cache manager includes the parts for its backing store and eventual
        /// encryption provider.
        /// </devdoc>
        void AddAdministrativeTemplateDirectivesForCacheManagers(AdmContentBuilder contentBuilder,
                                                                 CacheManagerSettings configurationSection,
                                                                 IConfigurationSource configurationSource,
                                                                 String sectionKey)
        {
            String cacheManagersKey       = sectionKey + @"\" + CacheManagersKeyName;
            String backingStoresKey       = sectionKey + @"\" + BackingStoresKeyName;
            String encryptionProvidersKey = sectionKey + @"\" + EncryptionProvidersKeyName;

            contentBuilder.StartCategory(Resources.CacheManagersCategoryName);
            {
                foreach (CacheManagerDataBase cacheManagerDataBase in configurationSection.CacheManagers)
                {
                    if (cacheManagerDataBase is CustomCacheManagerData)
                    {
                        customManageabilityProvider.AddAdministrativeTemplateDirectives(contentBuilder,
                                                                                        cacheManagerDataBase, configurationSource, cacheManagersKey);
                    }
                    else
                    {
                        String cacheManagerPolicyKey = cacheManagersKey + @"\" + cacheManagerDataBase.Name;

                        contentBuilder.StartPolicy(String.Format(CultureInfo.InvariantCulture,
                                                                 Resources.CacheManagerPolicyNameTemplate,
                                                                 cacheManagerDataBase.Name),
                                                   cacheManagerPolicyKey);
                        {
                            if (cacheManagerDataBase is CacheManagerData)
                            {
                                CacheManagerData cacheManagerData = (CacheManagerData)cacheManagerDataBase;

                                contentBuilder.AddNumericPart(Resources.CacheManagerExpirationPollFrequencyInSecondsPartName,
                                                              CacheManagerExpirationPollFrequencyInSecondsPropertyName,
                                                              cacheManagerData.ExpirationPollFrequencyInSeconds);

                                contentBuilder.AddNumericPart(Resources.CacheManagerMaximumElementsInCacheBeforeScavengingPartName,
                                                              CacheManagerMaximumElementsInCacheBeforeScavengingPropertyName,
                                                              cacheManagerData.MaximumElementsInCacheBeforeScavenging);

                                contentBuilder.AddNumericPart(Resources.CacheManagerNumberToRemoveWhenScavengingPartName,
                                                              CacheManagerNumberToRemoveWhenScavengingPropertyName,
                                                              cacheManagerData.NumberToRemoveWhenScavenging);

                                // append the cache manager's backing store parts
                                contentBuilder.AddTextPart(Resources.BackingStoreSettingsPartName);
                                CacheStorageData backingStoreData
                                    = configurationSection.BackingStores.Get(cacheManagerData.CacheStorage);
                                ConfigurationElementManageabilityProvider backingStoreDataManageablityProvider
                                    = GetSubProvider(backingStoreData.GetType());
                                AddAdministrativeTemplateDirectivesForElement(contentBuilder,
                                                                              backingStoreData, backingStoreDataManageablityProvider,
                                                                              configurationSource,
                                                                              backingStoresKey);

                                // append the backing store's encryption provider parts
                                if (!String.IsNullOrEmpty(backingStoreData.StorageEncryption))
                                {
                                    contentBuilder.AddTextPart(Resources.StorageEncryptionProviderSettingsPartName);
                                    StorageEncryptionProviderData encryptionProviderData
                                        = configurationSection.EncryptionProviders.Get(backingStoreData.StorageEncryption);
                                    ConfigurationElementManageabilityProvider encryptionProviderDataManageabilityProvider
                                        = GetSubProvider(encryptionProviderData.GetType());
                                    AddAdministrativeTemplateDirectivesForElement(contentBuilder,
                                                                                  encryptionProviderData, encryptionProviderDataManageabilityProvider,
                                                                                  configurationSource,
                                                                                  encryptionProvidersKey);
                                }
                            }
                        }
                        contentBuilder.EndPolicy();
                    }
                }
            }
            contentBuilder.EndCategory();
        }
Пример #25
0
        /// <summary>
        /// <para>Gets the <see cref="StorageEncryptionProviderData"/> from configuration for the named <see cref="CacheManager"/></para>
        /// </summary>
        /// <param name="cacheManagerName">
        /// <para>The name of the <see cref="CacheManager"/>.</para>
        /// </param>
        /// <returns>
        /// <para>A <see cref="StorageEncryptionProviderData"/> object.</para>
        /// </returns>
        public virtual StorageEncryptionProviderData GetStorageEncryptionProviderData(string cacheManagerName)
        {
            CacheStorageData data = GetCacheStorageDataForCacheManager(cacheManagerName);

            return(data.StorageEncryption);
        }
        public void RegisteredCacheStorageDataProviderIsCalledWithCorrectOverrides()
        {
            MockConfigurationElementManageabilityProvider registeredProvider
                = new MockConfigurationElementManageabilityProvider();
            Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders
                = new Dictionary<Type, ConfigurationElementManageabilityProvider>();
            subProviders.Add(typeof(CacheStorageData), registeredProvider);
            provider = new CacheManagerSettingsManageabilityProvider(subProviders);

            CacheStorageData data = new CacheStorageData("store1", typeof(NullBackingStore));
            section.BackingStores.Add(data);

            MockRegistryKey machineStoresKey = new MockRegistryKey(false);
            machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.BackingStoresKeyName, machineStoresKey);
            MockRegistryKey machineStoreKey = new MockRegistryKey(false);
            machineStoresKey.AddSubKey("store1", machineStoreKey);
            MockRegistryKey machineOtherStoreKey = new MockRegistryKey(false);
            machineStoresKey.AddSubKey("store2", machineOtherStoreKey);

            MockRegistryKey userStoresKey = new MockRegistryKey(false);
            userKey.AddSubKey(CacheManagerSettingsManageabilityProvider.BackingStoresKeyName, userStoresKey);
            MockRegistryKey userStoreKey = new MockRegistryKey(false);
            userStoresKey.AddSubKey("store1", userStoreKey);
            MockRegistryKey userOtherStoreKey = new MockRegistryKey(false);
            userStoresKey.AddSubKey("store2", userOtherStoreKey);

            provider.OverrideWithGroupPolicies(section, true, machineKey, userKey);

            Assert.IsTrue(registeredProvider.called);
            Assert.AreSame(data, registeredProvider.LastConfigurationObject);
            Assert.AreEqual(machineStoreKey, registeredProvider.machineKey);
            Assert.AreEqual(userStoreKey, registeredProvider.userKey);

            Assert.IsTrue(
                MockRegistryKey.CheckAllClosed(machineStoresKey, machineStoreKey, machineOtherStoreKey,
                                               userStoresKey, userStoreKey, userOtherStoreKey));
        }
 public TestCachingConfigurationView(CacheStorageData data, ConfigurationContext context) : base(context)
 {
     this.data = data;
 }
Пример #28
0
 public static void GenerateWmiObjects(CacheStorageData configurationObject,
                                       ICollection <ConfigurationSetting> wmiSettings)
 {
     wmiSettings.Add(new NullBackingStoreSetting(configurationObject.Name, configurationObject.StorageEncryption));
 }
Пример #29
0
        /// <summary>
        /// <para>Gets the <see cref="Type"/> of the <see cref="IBackingStore"/> for the factory to create for a <see cref="CacheManager"/>.</para>
        /// </summary>
        /// <param name="cacheManagerName">
        /// <para>The name of the cache manager to create the <see cref="IBackingStore"/>.</para>
        /// </param>
        /// <returns>
        /// <para>The <see cref="Type"/> of the <see cref="IBackingStore"/> to create.</para>
        /// </returns>
        protected override Type GetConfigurationType(string cacheManagerName)
        {
            CacheStorageData cacheStorageData = GetCacheStorageData(cacheManagerName);

            return(GetType(cacheStorageData.TypeName));
        }
Пример #30
0
 /// <summary>
 /// Adds a <see cref="CacheStorageData"/> to the <see cref="CacheManagerSettings"/> as well as adds a reference to the <see cref="CacheManager"/> instance currently being configured.
 /// </summary>
 /// <param name="backingStore">The <see cref="CacheStorageData"/> that should be added to configuration.</param>
 protected void AddBackingStoreToCachingConfigurationAndCurrentCacheManager(CacheStorageData backingStore)
 {
     currentBackingStore = backingStore;
     contextExtension.CachingSettings.BackingStores.Add(backingStore);
     contextExtension.CacheManager.CacheStorage = backingStore.Name;
 }
        public void RegisteredCacheStorageDataProviderIsCalledWithNoOverrides()
        {
            MockConfigurationElementManageabilityProvider registeredProvider
                = new MockConfigurationElementManageabilityProvider();
            Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders
                = new Dictionary<Type, ConfigurationElementManageabilityProvider>();
            subProviders.Add(typeof(CacheStorageData), registeredProvider);
            provider = new CacheManagerSettingsManageabilityProvider(subProviders);

            CacheStorageData data = new CacheStorageData("store1", typeof(NullBackingStore));
            section.BackingStores.Add(data);

            provider.OverrideWithGroupPolicies(section, true, machineKey, userKey);

            Assert.IsTrue(registeredProvider.called);
            Assert.AreSame(data, registeredProvider.LastConfigurationObject);
            Assert.AreEqual(null, registeredProvider.machineKey);
            Assert.AreEqual(null, registeredProvider.userKey);
        }