void IAddTo.AddTo(IConfigurationSource configurationSource)
        {
            var section = new ConnectionStringsSection();
            foreach(var builder in builders)
            {
                builder.AddTo(section);
            }

            configurationSource.Add("connectionStrings", section);

            var databaseSettings = new DatabaseSettings {DefaultDatabase = defaultDatabase};
            configurationSource.Add(DatabaseSettings.SectionName, databaseSettings);
        }
        public virtual void Save(IServiceProvider serviceProvider)
        {
            ConfigurationSectionInfo info = null;
            ConfigurationNode        node = ServiceHelper.GetCurrentRootNode(serviceProvider);

            try
            {
                IConfigurationSource    configurationSource = GetConfigurationSource(serviceProvider);
                IConfigurationParameter parameter           = GetConfigurationParameter(serviceProvider);

                info = GetConfigurationSectionInfo(serviceProvider);
                if (null != info && !string.IsNullOrEmpty(info.SectionName))
                {
                    if (null != info.Section)
                    {
                        configurationSource.Add(parameter, info.SectionName, info.Section);
                    }
                    else
                    {
                        configurationSource.Remove(parameter, info.SectionName);
                    }
                }
            }
            catch (Exception e)
            {
                ServiceHelper.LogError(serviceProvider, info != null ? info.Node : node, e);
            }
        }
Пример #3
0
        public void AddGetAndRemoveASection()
        {
            IConfigurationSource source = ConfigurationSourceFactory.Create("sqlSource");

            Assert.AreEqual(typeof(SqlConfigurationSource), source.GetType());

            DummySection dummySection1 = new DummySection();

            dummySection1.Value = 10;

            source.Add(CreateParameter(), localSection, dummySection1);

            ConfigurationSection newSection = source.GetSection(localSection);

            Assert.AreEqual(typeof(DummySection), newSection.GetType());

            DummySection dummySection2 = newSection as DummySection;

            Assert.AreEqual(dummySection1, dummySection2);

            source.Remove(CreateParameter(), localSection);

            newSection = source.GetSection(localSection);
            Assert.AreEqual(null, newSection);
        }
 /// <summary>
 /// Updates a configuration source replacing any existing sections with those
 /// built up with the builder.
 /// </summary>
 /// <param name="source"></param>
 public void UpdateConfigurationWithReplace(IConfigurationSource source)
 {
     foreach (var section in configurationSource.sections)
     {
         source.Remove(section.Key);
         source.Add(section.Key, section.Value);
     }
 }
        void IAddTo.AddTo(IConfigurationSource configurationSource)
        {
            var section = new ConnectionStringsSection();

            foreach (var builder in builders)
            {
                builder.AddTo(section);
            }

            configurationSource.Add("connectionStrings", section);

            var databaseSettings = new DatabaseSettings {
                DefaultDatabase = defaultDatabase
            };

            configurationSource.Add(DatabaseSettings.SectionName, databaseSettings);
        }
 public void AddTo(IConfigurationSource configurationSource)
 {
     var section = new PolicyInjectionSettings();
     foreach(var builder in builders)
     {
         builder.AddTo(section);
     }
     configurationSource.Add(BlockSectionNames.PolicyInjection, section);
 }
Пример #7
0
        public void AddTo(IConfigurationSource configurationSource)
        {
            var section = new CryptographySettings();

            foreach (var builder in hashProviderBuilders)
            {
                builder.AddTo(section);
            }
            configurationSource.Add(BlockSectionNames.Cryptography, section);
        }
Пример #8
0
        public void AddTo(IConfigurationSource configurationSource)
        {
            var section = new PolicyInjectionSettings();

            foreach (var builder in builders)
            {
                builder.AddTo(section);
            }
            configurationSource.Add(BlockSectionNames.PolicyInjection, section);
        }
Пример #9
0
        public static void SetServerDBInfo(
            string ProjectAllocationServer,
            string ProjectAllocationDB,
            string SQLUserID,
            string SQLPwd,
            string TimeOut)
        {
            ConnectionStringsSection current = configSource.GetSection("connectionStrings") as ConnectionStringsSection;

            current.ConnectionStrings[1].ConnectionString = string.Format(Constant.CONNECTIONSTRING, ProjectAllocationServer, ProjectAllocationDB, SQLUserID, SQLPwd, TimeOut);
            configSource.Add("connectionStrings", current);

            settings["ProjectAllocationServer"].Value = ProjectAllocationServer;
            settings["ProjectAllocationDB"].Value     = ProjectAllocationDB;
            settings["SQLUserID"].Value = SQLUserID;
            settings["SQLPwd"].Value    = SQLPwd;
            settings["TimeOut"].Value   = TimeOut;
            settings["IsSetted"].Value  = true.ToString();
            configSource.Add("appSettings", appsettings);
        }
        /// <summary>
        /// Checks whether a call to <see cref="IConfigurationSource.Add(string, ConfigurationSection)"/> should be deferred to a subordinate source.<br/>
        /// If the call should be deferred, adds the <paramref name="configurationSection"/> to the appropriate source and returns <see langword="true"/>.<br/>
        /// If the call should not be deferred returns <see langword="true"/>.
        /// </summary>
        /// <param name="sectionName">The name of the section that should be added to configuration.</param>
        /// <param name="configurationSection">The section that should be added to configuration.</param>
        /// <returns><see langword="true"/> if the section was added in a subordinate source, otherwise <see langword="false"/>.</returns>
        /// <seealso cref="IConfigurationSource.Add(string, ConfigurationSection)"/>
        protected override bool DoCheckAddSection(string sectionName, ConfigurationSection configurationSection)
        {
            string sourceNameForSection;

            if (sectionRedirectTable.TryGetValue(sectionName, out sourceNameForSection))
            {
                IConfigurationSource subordinateSource = GetSubordinateSource(sourceNameForSection);
                subordinateSource.Add(sectionName, configurationSection);
                return(true);
            }
            return(false);
        }
Пример #11
0
        public void AddTo(IConfigurationSource configurationSource)
        {
            var section = new ExceptionHandlingSettings();

            foreach (var builder in builders)
            {
                section.ExceptionPolicies.Add(builder.GetPolicyData());
            }

            configurationSource.Add(BlockSectionNames.ExceptionHandling,
                                    section);
        }
        protected override void Arrange()
        {
            base.Arrange();

            mergedConfiguration = new DictionaryConfigurationSource();
            mergedConfiguration.Add(
                           InstrumentationConfigurationSection.SectionName,
                           new InstrumentationConfigurationSection(false, true));

            Builder
                .ConfigureInstrumentation()
                    .EnablePerformanceCounters();
        }
Пример #13
0
        protected override void Arrange()
        {
            base.Arrange();

            mergedConfiguration = new DictionaryConfigurationSource();
            mergedConfiguration.Add(
                InstrumentationConfigurationSection.SectionName,
                new InstrumentationConfigurationSection(false, true));

            Builder
            .ConfigureInstrumentation()
            .EnablePerformanceCounters();
        }
Пример #14
0
        public void GetsNotificationWhenUpdatingAndRemovingSections()
        {
            ConfigurationChangeWatcher.SetDefaultPollDelayInMilliseconds(50);
            IConfigurationSource source = ConfigurationSourceFactory.Create("sqlSource");

            Assert.AreEqual(typeof(SqlConfigurationSource), source.GetType());

            DummySection dummySection1 = new DummySection();

            dummySection1.Value = 10;

            source.Add(CreateParameter(), localSection, dummySection1);
            bool sourceChanged = false;
            SqlConfigurationSource sqlSource = source as SqlConfigurationSource;

            sqlSource.AddSectionChangeHandler(localSection, delegate(object o, ConfigurationChangedEventArgs args)
            {
                sourceChanged = true;
            });

            ConfigurationSection newSection = source.GetSection(localSection);

            Assert.AreEqual(typeof(DummySection), newSection.GetType());

            DummySection dummySection2 = newSection as DummySection;

            Assert.AreEqual(dummySection1, dummySection2);

            //update the section
            dummySection2.Value = 15;
            sqlSource.Add(CreateParameter(), localSection, dummySection2);

            Thread.Sleep(500);

            Assert.IsTrue(sourceChanged);
            sourceChanged = false;

            //remove the section
            sqlSource.Remove(CreateParameter(), localSection);

            Thread.Sleep(500);

            Assert.IsTrue(sourceChanged);
            sourceChanged = false;

            newSection = sqlSource.GetSection(localSection);
            Assert.AreEqual(null, newSection);
        }
Пример #15
0
 public void AddTo(IConfigurationSource configurationSource)
 {
     configurationSource.Add(TypeRegistrationProvidersConfigurationSection.SectionName,
                             section);
 }