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


C# IConfiguration.AddChild方法代码示例

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


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

示例1: AddNewFlatConfig

        /// <summary>
        /// <para>
        /// Adds a new flat configuration node with given name attribute and values
        /// </para>
        /// </summary>
        ///
        /// <param name="parent">
        /// The parent configuration of the new node.
        /// </param>
        /// <param name="name">
        /// The name of the new configuration.
        /// </param>
        /// <param name="values">
        /// The values of the new configuration.
        /// </param>
        /// <param name="propertyIndex">
        /// The index of the new node.
        /// </param>
        ///
        /// <returns>
        /// The configuration created.
        /// </returns>
        private static void AddNewFlatConfig(IConfiguration parent,
            int propertyIndex, string name, params object[] values)
        {
            if (values[0] == null)
            {
                return;
            }

            // The property node
            IConfiguration child = new DefaultConfiguration(ConfigProperty + "_" + propertyIndex);
            child.SetSimpleAttribute(ConfigName, name);

            // The value nodes
            int index = 0;
            foreach (object value in values)
            {
                if (value != null)
                {
                    IConfiguration valueNode = new DefaultConfiguration(ConfigValue + "_" + (++index));
                    valueNode.SetSimpleAttribute(ConfigNodeValue, value.ToString());

                    child.AddChild(AbstractConfiguration.Synchronized(valueNode));
                }
            }

            // Add the new property node
            parent.AddChild(AbstractConfiguration.Synchronized(child));
        }
开发者ID:bage,项目名称:Demo-Logging-Wrapper,代码行数:50,代码来源:ConfigurationAPIObjectFactory.cs

示例2: AddNewNestedConfig

        /// <summary>
        /// <para>
        /// Adds a new nested configuration node with given name and values
        /// </para>
        /// </summary>
        ///
        /// <param name="parent">
        /// The parent configuration of the new node.
        /// </param>
        /// <param name="name">
        /// The name of the new configuration.
        /// </param>
        /// <param name="values">
        /// The values of the new configuration.
        /// </param>
        ///
        /// <returns>
        /// The configuration created.
        /// </returns>
        private static IConfiguration AddNewNestedConfig(IConfiguration parent,
            string name, params object[] values)
        {
            if (values[0] == null)
            {
                return null;
            }

            IConfiguration child = new DefaultConfiguration(name);
            child.SetAttribute(ConfigValue, ToStringArray(values));

            parent.AddChild(AbstractConfiguration.Synchronized(child));
            return child;
        }
开发者ID:bage,项目名称:Demo-Logging-Wrapper,代码行数:33,代码来源:ConfigurationAPIObjectFactory.cs

示例3: SaveNestedParameters

        /// <summary>
        /// <para>
        /// Saves the given parameters in NESTED hierarchical structure.
        /// </para>
        /// </summary>
        ///
        /// <param name="types">
        /// The parameter types.
        /// </param>
        /// <param name="values">
        /// The parameter values.
        /// </param>
        /// <param name="parent">
        /// The object configuration.
        /// </param>
        private void SaveNestedParameters(IConfiguration parent, string[] types, object[] values)
        {
            IConfiguration paramsConfig = new DefaultConfiguration(ConfigParameters);

            for (int i = 0; i < types.Length; ++i)
            {
                string childName = ConfigParameter + "_" + (i + 1);
                IConfiguration paramConfig;
                if (types[i] == NullType)
                {
                    // null parameter
                    paramConfig = AddNewNestedConfig(paramsConfig, childName, String.Empty);
                }
                else
                {
                    Array array = values[i] as Array;
                    if (array == null)
                    {
                        // Simple parameter
                        paramConfig = AddNewNestedConfig(paramsConfig, childName, values[i]);
                    }
                    else
                    {
                        // Array parameter
                        paramConfig = AddNewNestedConfig(paramsConfig, childName, ToStringArray(array));
                    }
                }

                // Add the type of the parameter
                paramConfig.SetSimpleAttribute(ConfigType, types[i]);
            }

            parent.AddChild(AbstractConfiguration.Synchronized(paramsConfig));
        }
开发者ID:bage,项目名称:Demo-Logging-Wrapper,代码行数:49,代码来源:ConfigurationAPIObjectFactory.cs

示例4: SaveNestedMethodDefinition

        /// <summary>
        /// <para>
        /// Saves the given method definition in NESTED hierarchical structure.
        /// </para>
        /// </summary>
        ///
        /// <param name="name">
        /// The method unique name.
        /// </param>
        /// <param name="definition">
        /// The method definition to be saved.
        /// </param>
        /// <param name="parent">
        /// The methods configuration.
        /// </param>
        private void SaveNestedMethodDefinition(IConfiguration parent, string name, MethodCallDefinition definition)
        {
            // The config of the definition
            IConfiguration methodConfig = new DefaultConfiguration(name);

            // Write all simple attributes of the definition
            AddNewNestedConfig(methodConfig, ConfigIgnoreCase, definition.IgnoreCase);
            AddNewNestedConfig(methodConfig, ConfigMethodName, definition.MethodName);
            AddNewNestedConfig(methodConfig, ConfigIsProperty, definition.IsProperty);

            if (definition.ParamTypes.Length > 0)
            {
                // Write the parameter definitions of the method
                SaveNestedParameters(methodConfig, definition.ParamTypes, definition.ParamValues);
            }

            // Add the new method configuration into methods config
            parent.AddChild(AbstractConfiguration.Synchronized(methodConfig));
        }
开发者ID:bage,项目名称:Demo-Logging-Wrapper,代码行数:34,代码来源:ConfigurationAPIObjectFactory.cs

示例5: SetUp

        protected void SetUp()
        {
            namedMsg = new NamedMessage(MESSAGE, NAMEDMESSAGE, new List<string>(PARAMETER_NAMES),
                Level.ERROR);

            config = new DefaultConfiguration("default");
            config.SetSimpleAttribute("logger_name", LOGGER_NAME);
            config.SetSimpleAttribute("default_level", DEFAULT_LEVEL.ToString());

            IConfiguration msgsConfig = new DefaultConfiguration("NamedMessages");

            IConfiguration msgConfig = new DefaultConfiguration(NAMEDMESSAGE);
            msgConfig.SetSimpleAttribute("text", MESSAGE);
            msgConfig.SetSimpleAttribute("default_level", Level.DEBUG.ToString());
            msgConfig.SetAttribute("parameters", new object[] {PARAMETER_NAMES[0], PARAMETER_NAMES[1]});
            msgsConfig.AddChild(msgConfig);

            config.AddChild(msgsConfig);

            simpleLogger = new SimpleLogger(config);

            anotherLogger = new AnotherSimpleLogger(EXCEPTION_LOGGER_NAME);

            logger = new ExceptionSafeLogger(simpleLogger, anotherLogger);
        }
开发者ID:bage,项目名称:Demo-Logging-Wrapper,代码行数:25,代码来源:ExceptionSafeLoggerUnitTest.cs

示例6: SetUp

        protected void SetUp()
        {
            namedMsg = new NamedMessage(MESSAGE, NAMEDMESSAGE, new List<string>(PARAMETER_NAMES),
                Level.ERROR);

            config = new DefaultConfiguration("default");
            config.SetSimpleAttribute("logger_name", LOGNAME);
            config.SetSimpleAttribute("default_level", DEFAULT_LEVEL.ToString());
            config.SetSimpleAttribute("config_file", CONFIG_FILE);

            IConfiguration msgsConfig = new DefaultConfiguration("NamedMessages");

            IConfiguration msgConfig = new DefaultConfiguration(NAMEDMESSAGE);
            msgConfig.SetSimpleAttribute("text", MESSAGE);
            msgConfig.SetSimpleAttribute("default_level", Level.DEBUG);
            msgConfig.SetAttribute("parameters", new object[] {PARAMETER_NAMES[0], PARAMETER_NAMES[1]});
            msgsConfig.AddChild(msgConfig);

            config.AddChild(msgsConfig);

            logger = new Log4NETImpl(config);
        }
开发者ID:bage,项目名称:Demo-Logging-Wrapper,代码行数:22,代码来源:Log4NETImplUnitTest.cs

示例7: SetUp

        protected void SetUp()
        {
            IList<string> param = new List<string>();
            param.Add("param1");
            param.Add("param2");

            namedMsg = new NamedMessage("text1", NAME1, param, Level.ERROR);

            msgs = new Dictionary<string, NamedMessage>();
            msgs.Add(NAME1, namedMsg);
            msgs.Add(NAME2, new NamedMessage("text2", NAME2, new List<string>(), Level.WARN));

            config = new DefaultConfiguration("default");
            config.SetSimpleAttribute("logger_name", LOGNAME);
            config.SetSimpleAttribute("default_level", LEVEL.ToString());

            IConfiguration msgsConfig = new DefaultConfiguration("NamedMessages");

            IConfiguration msgConfig = new DefaultConfiguration(NAME1);
            msgConfig.SetSimpleAttribute("text", "text1");
            msgConfig.SetSimpleAttribute("default_level", Level.ERROR);
            msgConfig.SetAttribute("parameters", new object[] {"param1", "param2"});
            msgsConfig.AddChild(msgConfig);

            msgConfig = new DefaultConfiguration(NAME2);
            msgConfig.SetSimpleAttribute("text", "text2");
            msgConfig.SetSimpleAttribute("default_level", Level.WARN);
            msgsConfig.AddChild(msgConfig);

            config.AddChild(msgsConfig);

            logger = new SimpleLogger(LOGNAME, LEVEL, msgs);
        }
开发者ID:bage,项目名称:Demo-Logging-Wrapper,代码行数:33,代码来源:LoggerUnitTest.cs


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