本文整理汇总了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));
}
示例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;
}
示例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));
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}