public void NoParentSectionsAllowed()
 {
     IConfigurationSectionHandler handler = new ConfigurationSectionHandler();
     Assert.Throws(Is.TypeOf<ConfigurationException>().And.Message.EqualTo("parent configuration sections are not allowed")
                  , delegate {
                           handler.Create(new LogSetting(typeof (ConsoleOutLoggerFactoryAdapter), null), 
                                          null,
                                          null);
                   });
 }
        public void NoParentSectionsAllowed()
        {
            IConfigurationSectionHandler handler = new ConfigurationSectionHandler();

            Assert.Throws(Is.TypeOf <ConfigurationException>().And.Message.EqualTo("parent configuration sections are not allowed")
                          , delegate {
                handler.Create(new LogSetting(typeof(ConsoleOutLoggerFactoryAdapter), null),
                               null,
                               null);
            });
        }
 /// <summary>
 /// Parses the configuration section and returns the resulting object.
 /// </summary>
 /// <param name="sectionName">Name of the configuration section.</param>
 /// <returns>
 /// Object created by a corresponding <see cref="System.Configuration.IConfigurationSectionHandler"/>.
 /// </returns>
 /// <remarks>
 /// 	<p>
 /// Primary purpose of this method is to allow us to parse and
 /// load configuration sections using the same API regardless
 /// of the .NET framework version.
 /// </p>
 /// </remarks>
 /// <see cref="ConfigurationSectionHandler"/>
 public object GetSection(string sectionName)
 {
     ConfigurationSectionHandler handler = new ConfigurationSectionHandler();
     return handler.Create(null, null, BuildConfigurationSection(XmlString));
 }
예제 #4
0
        /// <summary>
        /// Parses the configuration section and returns the resulting object.
        /// </summary>
        /// <param name="sectionName">Name of the configuration section.</param>
        /// <returns>
        /// Object created by a corresponding <see cref="System.Configuration.IConfigurationSectionHandler"/>.
        /// </returns>
        /// <remarks>
        ///     <p>
        /// Primary purpose of this method is to allow us to parse and
        /// load configuration sections using the same API regardless
        /// of the .NET framework version.
        /// </p>
        /// </remarks>
        /// <see cref="ConfigurationSectionHandler"/>
        public object GetSection(string sectionName)
        {
            ConfigurationSectionHandler handler = new ConfigurationSectionHandler();

            return(handler.Create(null, null, BuildConfigurationSection(XmlString)));
        }