public void FixtureSetup() { byte[] key = new byte[] { 0, 1, 2, 3, 4 }; CryptographySettings settings = (CryptographySettings)context.GetConfiguration(CryptographySettings.SectionName); ((KeyedHashAlgorithmProviderData)settings.HashProviders[hashInstance]).Key = key; }
public void CurrentTest() { ConfigurationContext context = ConfigurationManager.CreateContext(); object data = context.GetConfiguration("ReadOnlyConfig"); Assert.IsNull(data); ConfigurationContext context2 = ConfigurationManager.CreateContext(); Assert.IsTrue(!ReferenceEquals(context, context2)); }
/// <summary> /// <para>Gets the <see cref="ExceptionHandlerData"/> from configuration for the policy and specific exception type.</para> /// </summary> /// <param name="policyName"> /// <para>The name of the <see cref="ExceptionPolicy"/> for the data.</para> /// </param> /// <param name="exceptionTypeName"> /// <para>The <see cref="Exception"/> type that will be handled.</para> /// </param> /// <param name="handlerName"><para>The name of the handler to retrieve from configuration.</para></param> /// <returns> /// <para>An <see cref="ExceptionHandlerData"/> object.</para> /// </returns> public virtual ExceptionHandlerData GetExceptionHandlerData(string policyName, string exceptionTypeName, string handlerName) { ValidatePolicyName(policyName); ValidateExceptionTypeName(exceptionTypeName); ValidateHandlerName(handlerName); ExceptionHandlingSettings settings = (ExceptionHandlingSettings)ConfigurationContext.GetConfiguration(ExceptionHandlingSettings.SectionName); return(GetExceptionHandlerData(settings, policyName, exceptionTypeName, handlerName)); }
public void WhenCreatingAContextMakeSureThatAllSectionsAreAddedToTheCache() { const string sectionA = "SectionA"; const string sectionB = "SectionB"; const string sectionAData = "SectionAData"; const string sectionBData = "SectionBData"; ConfigurationDictionary configurationDictionary = new ConfigurationDictionary(); configurationDictionary.Add(sectionA, sectionAData); configurationDictionary.Add(sectionB, sectionBData); configurationDictionary.Add(ConfigurationSettings.SectionName, new ConfigurationSettings()); ConfigurationContext context = ConfigurationManager.CreateContext(configurationDictionary); Assert.IsFalse(context.disposableWrapper.ConfigurationBuilder.CacheContains(ConfigurationSettings.SectionName), "Cache should not " + ConfigurationSettings.SectionName); Assert.IsTrue(context.disposableWrapper.ConfigurationBuilder.CacheContains(sectionA)); Assert.IsTrue(context.disposableWrapper.ConfigurationBuilder.CacheContains(sectionB)); Assert.AreEqual(sectionAData, context.GetConfiguration(sectionA)); Assert.AreEqual(sectionBData, context.GetConfiguration(sectionB)); }
public void ConstructorWithConfigurationDictionaryTest() { ConfigurationDictionary dictionary = new ConfigurationDictionary(); object expected = new object(); dictionary.Add("section1", expected); ConfigurationContext context = ConfigurationManager.CreateContext(dictionary); object actual = context.GetConfiguration("section1"); Assert.AreSame(expected, actual); }
public void FixtureSetup() { byte[] key = new byte[32]; CryptographyUtility.GetRandomBytes(key); CryptographySettings settings = (CryptographySettings)context.GetConfiguration(CryptographySettings.SectionName); ((SymmetricAlgorithmProviderData)settings.SymmetricCryptoProviders[symmetricInstanceName]).Key = key; SymmetricCryptoProviderFactory factory = new SymmetricCryptoProviderFactory(context); symmProvider = factory.CreateSymmetricCryptoProvider(symmetricInstanceName); }
/// <summary> /// <para>Gets the named <see cref="SymmetricCryptoProviderData"/> from the <see cref="CryptographySettings"/>.</para> /// </summary> /// <param name="symmetricProviderName"> /// <para>The name of the <see cref="SymmetricCryptoProviderData"/>.</para> /// </param> /// <returns> /// <para>The named <see cref="SymmetricCryptoProviderData"/> from the <see cref="CryptographySettings"/>.</para> /// </returns> public virtual SymmetricCryptoProviderData GetSymmetricCryptoProviderData(string symmetricProviderName) { CryptographySettings settings = ConfigurationContext.GetConfiguration(CryptographySettings.SectionName) as CryptographySettings; if (settings == null) { throw new ConfigurationException(SR.ExceptionCryptoSettingsMissing); } SymmetricCryptoProviderData symmetricCryptoProviderData = settings.SymmetricCryptoProviders[symmetricProviderName]; if (symmetricCryptoProviderData == null) { throw new ConfigurationException(SR.ExceptionNoCryptoProvider(symmetricProviderName)); } return(symmetricCryptoProviderData); }
public void RuntimeTest() { GeneratedHierarchy.Open(); Assert.AreEqual(0, ConfigurationErrorsCount); ConfigurationContext builder = GeneratedHierarchy.ConfigurationContext; if (builder.IsValidSection(DistributorSettings.SectionName)) { DistributorSettings distributorSettings = builder.GetConfiguration(DistributorSettings.SectionName) as DistributorSettings; if (distributorSettings != null) { DistributorSettingsNode distributorSettingsNode = new DistributorSettingsNode(distributorSettings); foreach (ConfigurationNode node in distributorSettingsNode.Nodes) { if (node is SinkCollectionNode) { SinkCollectionNode sinkCollectionNode = (SinkCollectionNode)node; Assert.AreEqual(4, sinkCollectionNode.SinkDataCollection.Count); } else if (node is FormatterCollectionNode) { FormatterCollectionNode formatterCollectionNode = (FormatterCollectionNode)node; Assert.AreEqual(4, formatterCollectionNode.FormatterDataCollection.Count); } else if (node is CategoryCollectionNode) { CategoryCollectionNode categoryCollectionNode = (CategoryCollectionNode)node; Assert.AreEqual(2, categoryCollectionNode.CategoryDataCollection.Count); } } MsmqDistributorServiceNode msmqNode = new MsmqDistributorServiceNode(distributorSettings.DistributorService); Assert.IsNotNull(msmqNode.MsmqPath); } else { Assert.Fail(String.Format("Can not load section: {0}", DistributorSettings.SectionName)); } } }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(CryptographySettings.SectionName)) { CryptographySettings cryptographySettings = null; CryptographySettingsNode cryptographySettingsNode = null; try { cryptographySettings = (CryptographySettings)configurationContext.GetConfiguration(CryptographySettings.SectionName); cryptographySettingsNode = new CryptographySettingsNode(cryptographySettings); ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider); configurationNode.Nodes.Add(cryptographySettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, cryptographySettingsNode, e); } } }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(DynamicQuerySettings.SectionName)) { DynamicQuerySettings dynamicQuerySettings = null; DynamicQuerySettingsNode dynamicQuerySettingsNode = null; try { dynamicQuerySettings = configurationContext.GetConfiguration(DynamicQuerySettings.SectionName) as DynamicQuerySettings; dynamicQuerySettingsNode = new DynamicQuerySettingsNode(dynamicQuerySettings); ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider); configurationNode.Nodes.Add(dynamicQuerySettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, dynamicQuerySettingsNode, e); } } }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(DatabaseSettings.SectionName)) { DatabaseSettings databaseSettings = null; DatabaseSettingsNode databaseSettingsNode = null; try { databaseSettings = (DatabaseSettings)configurationContext.GetConfiguration(DatabaseSettings.SectionName); databaseSettingsNode = new DatabaseSettingsNode(databaseSettings); ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider); configurationNode.Nodes.Add(databaseSettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, databaseSettingsNode, e); } } }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public override void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(DistributorSettings.SectionName)) { DistributorSettings distributorSettings = null; DistributorSettingsNode distributorSettingsNode = null; try { distributorSettings = (DistributorSettings)configurationContext.GetConfiguration(DistributorSettings.SectionName); distributorSettingsNode = new DistributorSettingsNode(distributorSettings); ConfigurationNode configurationNode = GetLoggingSettingsNode(serviceProvider); configurationNode.Nodes.Add(distributorSettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, distributorSettingsNode, e); } } }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(ExceptionHandlingSettings.SectionName)) { ExceptionHandlingSettings exceptionHandlingSettings = null; ExceptionHandlingSettingsNode exceptionHandlingSettingsNode = null; try { exceptionHandlingSettings = (ExceptionHandlingSettings)configurationContext.GetConfiguration(ExceptionHandlingSettings.SectionName); exceptionHandlingSettingsNode = new ExceptionHandlingSettingsNode(exceptionHandlingSettings); ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider); configurationNode.Nodes.Add(exceptionHandlingSettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, exceptionHandlingSettingsNode, e); } } }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(SecuritySettings.SectionName)) { SecuritySettings securitySettings = null; SecuritySettingsNode securitySettingsNode = null; try { securitySettings = (SecuritySettings)configurationContext.GetConfiguration(SecuritySettings.SectionName); securitySettingsNode = new SecuritySettingsNode(securitySettings); ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider); configurationNode.Nodes.Add(securitySettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, securitySettingsNode, e); } } }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public override void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(LoggingSettings.SectionName)) { LoggingSettings loggingSettings = null; ClientSettingsNode clientSettingsNode = null; try { loggingSettings = (LoggingSettings)configurationContext.GetConfiguration(LoggingSettings.SectionName); clientSettingsNode = new ClientSettingsNode(loggingSettings); ConfigurationNode configurationNode = GetLoggingSettingsNode(serviceProvider); configurationNode.Nodes.Add(clientSettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, clientSettingsNode, e); } } }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(CacheManagerSettings.SectionName)) { CacheManagerSettingsNode cacheManagerSettingsNode = null; try { CacheManagerSettings settings = configurationContext.GetConfiguration(CacheManagerSettings.SectionName) as CacheManagerSettings; if (settings != null) { cacheManagerSettingsNode = new CacheManagerSettingsNode(settings); ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider); configurationNode.Nodes.Add(cacheManagerSettingsNode); } } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, cacheManagerSettingsNode, e); } } }
public void RuntimeTest() { GeneratedHierarchy.Open(); Assert.AreEqual(0, ConfigurationErrorsCount); ConfigurationContext configurationContext = GeneratedHierarchy.ConfigurationContext; if (configurationContext.IsValidSection(LoggingSettings.SectionName)) { LoggingSettings clientSettings = configurationContext.GetConfiguration(LoggingSettings.SectionName) as LoggingSettings; if (clientSettings != null) { ClientSettingsNode settingsNode = new ClientSettingsNode(clientSettings); Assert.AreEqual(CategoryFilterMode.DenyAllExceptAllowed, settingsNode.CategoryFilterSettings.CategoryFilterMode); Assert.AreEqual(false, settingsNode.LoggingEnabled); Assert.AreEqual(1, settingsNode.MinimumPriority); Assert.AreEqual(false, settingsNode.TracingEnabled); } } else { Assert.Fail(String.Format("Can not load section: {0}", LoggingSettings.SectionName)); } }
/// <summary> /// <para>Gets the <see cref="CryptographySettings"/>.</para> /// </summary> /// <returns> /// <para>The <see cref="CryptographySettings"/>.</para> /// </returns> public virtual CryptographySettings GetCryptographySettings() { return(ConfigurationContext.GetConfiguration(CryptographySettings.SectionName) as CryptographySettings); }
/// <summary> /// <para>Gets the <see cref="DatabaseSettings"/> configuration data.</para> /// </summary> /// <returns> /// <para>The <see cref="DatabaseSettings"/> configuration data.</para> /// </returns> public virtual DatabaseSettings GetDatabaseSettings() { return((DatabaseSettings)ConfigurationContext.GetConfiguration(DatabaseSettings.SectionName)); }
/// <summary> /// <para>Gets the <see cref="SecuritySettings"/> configuration data.</para> /// </summary> /// <returns> /// <para>The <see cref="SecuritySettings"/> configuration data.</para> /// </returns> public virtual SecuritySettings GetSecuritySettings() { return((SecuritySettings)ConfigurationContext.GetConfiguration(SecuritySettings.SectionName)); }
/// <summary> /// Gets the <see cref="DistributorSettings"></see> from configuration /// </summary> /// <returns><see cref="DistributorSettings"></see> read from configuration</returns> public virtual DistributorSettings GetDistributorSettings() { return((DistributorSettings)ConfigurationContext.GetConfiguration(DistributorSettings.SectionName)); }
/// <summary> /// Gets the <see cref="LoggingSettings"></see> from configuration /// </summary> /// <returns><see cref="LoggingSettings"></see> object that contains the logging-specific configuration information</returns> public virtual LoggingSettings GetLoggingSettings() { return((LoggingSettings)ConfigurationContext.GetConfiguration(LoggingSettings.SectionName)); }
/// <summary> /// <para>Gets the <see cref="CacheManagerSettings"/> configuration data.</para> /// </summary> /// <returns> /// <para>The <see cref="CacheManagerSettings"/> configuration data.</para> /// </returns> public virtual CacheManagerSettings GetCacheManagerSettings() { return((CacheManagerSettings)ConfigurationContext.GetConfiguration(CacheManagerSettings.SectionName)); }
/// <summary> /// <para>Gets the <see cref="ExceptionHandlingSettings"/> configuration data.</para> /// </summary> /// <returns> /// <para>The <see cref="ExceptionHandlingSettings"/> configuration data.</para> /// </returns> public virtual ExceptionHandlingSettings GetExceptionHandlingSettings() { return((ExceptionHandlingSettings)ConfigurationContext.GetConfiguration(ExceptionHandlingSettings.SectionName)); }
public void FixtureSetup() { settings = (SecuritySettings)context.GetConfiguration(SecuritySettings.SectionName); }
private bool IsTracingEnabled() { LoggingSettings settings = (LoggingSettings)context.GetConfiguration(LoggingSettings.SectionName); return(settings.TracingEnabled); }