当前位置: 首页>>代码示例>>C#>>正文


C# IConfiguration.GetChild方法代码示例

本文整理汇总了C#中IConfiguration.GetChild方法的典型用法代码示例。如果您正苦于以下问题:C# IConfiguration.GetChild方法的具体用法?C# IConfiguration.GetChild怎么用?C# IConfiguration.GetChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IConfiguration的用法示例。


在下文中一共展示了IConfiguration.GetChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

 public void Configure(IConfiguration config)
 {
     Port = (int) config.GetChild("port", true).GetValue( typeof(int), 2 );
     Server = (String) config.GetChild("server", true).GetValue( typeof(String), "nonlocalhost" );
 }
开发者ID:BackupTheBerlios,项目名称:dpml-svn,代码行数:5,代码来源:MailServer.cs

示例2: Logger

        /// <summary>
        /// <para>
        /// Creates a new instance of the Logger with setting loaded from the given configuration.
        /// </para>
        /// <para>
        /// New in 3.0.
        /// </para>
        /// </summary>
        /// <param name="configuration">The configuration object to load settings from.</param>
        /// <exception cref="ArgumentNullException">If configuration is null.</exception>
        /// <exception cref="ConfigException">
        ///  If any of the configuration settings are missing or are invalid values.
        /// </exception>
        protected Logger(IConfiguration configuration)
        {
            Helper.ValidateNotNull(configuration, "configuration");

            // load the logger name from configuration (required)
            logname = Helper.GetStringAttribute(configuration, LOGGER_NAME, true);

            // load the default level from the properties dictionary (optional, default to Level.DEBUG)
            defaultLevel = Helper.GetLevelAttribute(configuration, DEFAULT_LEVEL, DEFAULT_LEVEL_VALUE);

            // load NamedMessages child configuration
            IConfiguration namedMessagesConfig = configuration.GetChild(NAMED_MESSAGES);

            namedMessages = new Dictionary<string, NamedMessage>();

            // for each child configuration in namedMessagesConfig,
            // create a NamedMessage with attributes loaded from configuration and add to namedMessages
            if (namedMessagesConfig != null)
            {
                foreach (IConfiguration child in namedMessagesConfig.Children)
                {
                    AddNamedMessage(child);
                }
            }
        }
开发者ID:bage,项目名称:Demo-Logging-Wrapper,代码行数:38,代码来源:Logger.cs


注:本文中的IConfiguration.GetChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。