private ConfigurationSettings CreateConfigurationSettings() { ConfigurationSettings data = new ConfigurationSettings("defaultName"); return data; }
public void Initialize() { ConfigurationChangeFileWatcher.SetDefaultPollDelayInMilliseconds(1000); configFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; configurationSettings = new ConfigurationSettings(); ConfigurationSectionData sectionA = new ConfigurationSectionData(sectionAName); configurationSettings.ConfigurationSections.Add(sectionA); sectionA.Transformer = new XmlSerializerTransformerData(sectionAName); sectionA.Transformer.TypeName = typeof(MockTransformer).AssemblyQualifiedName; XmlFileStorageProviderData storageProviderData = new XmlFileStorageProviderData(fooName, fooConfig); sectionA.StorageProvider = storageProviderData; ConfigurationSectionData sectionB = new ConfigurationSectionData("SectionB"); configurationSettings.ConfigurationSections.Add(sectionB); sectionB.Transformer = new XmlSerializerTransformerData(sectionAName); sectionB.Transformer.TypeName = typeof(XmlSerializerTransformer).AssemblyQualifiedName; XmlFileStorageProviderData fooStorageProviderData = new XmlFileStorageProviderData(fooName, fooConfig); sectionB.StorageProvider = fooStorageProviderData; }
public void ReadWriteWebConfigTest() { string configFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, webConfigFile); using (ConfigurationBuilder builder = new ConfigurationBuilder(configFile)) { ConfigurationSettings configData = new ConfigurationSettings(mockConfigSection); configData.ConfigurationSections.Add(GetConfigurationSection()); builder.WriteMetaConfiguration(configData); builder.WriteConfiguration(mockConfigSection, data); MockConfigurationData readData = builder.ReadConfiguration(mockConfigSection) as MockConfigurationData; Assert.IsNotNull(readData); Assert.AreEqual(data.ToString(), readData.ToString()); } }
private static ConfigurationSettings GetConfigurationSettings(IServiceProvider serviceProvider) { ConfigurationNode rootNode = ServiceHelper.GetCurrentRootNode(serviceProvider); ConfigurationSectionCollectionNode sectionsNode = rootNode.Hierarchy.FindNodeByType(rootNode, typeof(ConfigurationSectionCollectionNode)) as ConfigurationSectionCollectionNode; ConfigurationSettings configurationSettings = null; if (sectionsNode == null) { configurationSettings = new ConfigurationSettings(); } else { configurationSettings = sectionsNode.ConfigurationSettings; } return configurationSettings; }