private void GetSecondConfigurationSource()
        {
            var configSourceSection =
                (ConfigurationSourceSection)RootConfiguration.GetSection(ConfigurationSourceSection.SectionName);

            secondSource = (FileConfigurationSource)configSourceSection.Sources.Get(SecondSourceName).CreateSource();
        }
Exemplo n.º 2
0
        private void ChangeSourcesSection()
        {
            var sourcesSection = (ConfigurationSourceSection)RootConfiguration.GetSection(ConfigurationSourceSection.SectionName);

            var newSources = new ConfigurationSourceSection
            {
                ParentSource   = sourcesSection.ParentSource,
                SelectedSource = sourcesSection.SelectedSource
            };

            CopyData(sourcesSection.Sources, s => newSources.Sources.Add(s));
            CopyData(sourcesSection.RedirectedSections, r => newSources.RedirectedSections.Add(r));

            newSources.Sources.Get("Second Source").Name = "New Source Name";
            newSources.RedirectedSections.Get(LoggingSettings.SectionName).SourceName = "New Source Name";

            ((FileConfigurationSource)RootConfiguration).Save(ConfigurationSourceSection.SectionName, newSources);
        }