/// <summary> /// Process the "protectionProvider" xml node section /// </summary> /// <param name="sectionChildNode"></param> /// <param name="protectionSettings"></param> /// <param name="sectionSettings"></param> void ProcessProtectionProvider( XmlNode sectionChildNode, out DataProtectionProviderSettings protectionSettings, ConfigSectionSettings sectionSettings ) { // Initialize a new DataProtectionProviderSettings. protectionSettings = new DataProtectionProviderSettings(); // Get a collection of all the attributes. XmlAttributeCollection nodeAttributes = sectionChildNode.Attributes; //#region Remove the provider known attributes and load the struct values // Remove the assembly attribute from the node and set its value in DataProtectionProviderSettings. XmlNode currentAttribute = nodeAttributes.RemoveNamedItem( "assembly" ); if (currentAttribute != null) protectionSettings.AssemblyName = currentAttribute.Value; // Remove the type attribute from the node and set its value in DataProtectionProviderSettings. currentAttribute = nodeAttributes.RemoveNamedItem( "type" ); if (currentAttribute != null) protectionSettings.TypeName = currentAttribute.Value; //#endregion //#region Loop through any other attributes and load them into OtherAttributes // Loop through any other attributes and load them into OtherAttributes. for (int i = 0; i < nodeAttributes.Count; i++) { protectionSettings.AddOtherAttributes(nodeAttributes.Item(i).Name,nodeAttributes.Item(i).Value); } //#endregion // Set the DataProtectionProviderSettings to the section provider. sectionSettings.DataProtection = protectionSettings; }
/// <summary> /// Process the "configCache" xml node section /// </summary> /// <param name="sectionChildNode"></param> /// <param name="cacheSettings"></param> /// <param name="sectionSettings"></param> void ProcessConfigCacheSection( XmlNode sectionChildNode, out ConfigCacheSettings cacheSettings, ConfigSectionSettings sectionSettings ) { // Initialize a new ConfigCacheSettings. cacheSettings = new ConfigCacheSettings(); // Get a collection of all the attributes. XmlAttributeCollection nodeAttributes = sectionChildNode.Attributes; // Remove the enabled attribute from the node and set its value in ConfigCacheSettings. XmlNode currentAttribute = nodeAttributes.RemoveNamedItem( "enabled" ); if (currentAttribute != null && currentAttribute.Value.ToUpper( System.Globalization.CultureInfo.CurrentUICulture ) == "TRUE" ) cacheSettings.IsEnabled = true; // Remove the refresh attribute from the node and set its value in ConfigCacheSettings. currentAttribute = nodeAttributes.RemoveNamedItem( "refresh" ); if (currentAttribute != null) cacheSettings.Refresh = currentAttribute.Value; // Set the ConfigurationCacheSettings to the section cache. sectionSettings.Cache = cacheSettings; }
/// <summary> /// Process the "configSection" xml node section /// </summary> /// <param name="configChildNode"></param> /// <param name="sectionSettings"></param> /// <param name="configSettings"></param> void ProcessConfigSection( XmlNode configChildNode, out ConfigSectionSettings sectionSettings, ConfigurationManagementSettings configSettings ) { // Initialize a new ConfigSectionSettings. sectionSettings = new ConfigSectionSettings(); // Get a collection of all the attributes. XmlAttributeCollection nodeAttributes = configChildNode.Attributes; //#region Remove the known attributes and load the struct values // Remove the name attribute from the node and set its value in ConfigSectionSettings. XmlNode currentAttribute = nodeAttributes.RemoveNamedItem( "name" ); if (currentAttribute != null) sectionSettings.Name = currentAttribute.Value; // Loop through the section components and load them into the ConfigurationManagementSettings. ConfigCacheSettings cacheSettings; ConfigProviderSettings providerSettings; DataProtectionProviderSettings protectionSettings; foreach(XmlNode sectionChildNode in configChildNode.ChildNodes) { switch ( sectionChildNode.Name ) { case "configCache" : ProcessConfigCacheSection( sectionChildNode, out cacheSettings, sectionSettings ); break; case "configProvider" : ProcessConfigProviderSection( sectionChildNode, out providerSettings, sectionSettings ); break; case "protectionProvider" : ProcessProtectionProvider( sectionChildNode, out protectionSettings, sectionSettings ); break; default : break; } } //#endregion // Add the ConfigurationSectionSettings to the sections collection. configSettings.AddConfigurationSection(sectionSettings); }
/// <summary> /// Adds a ConfigSectionSettings to the arraylist of sections. /// </summary> public void AddConfigurationSection(ConfigSectionSettings configSection) { _configSections[ configSection.Name ] = configSection; }