本文整理匯總了C#中NLog.Config.NLogXmlElement.Elements方法的典型用法代碼示例。如果您正苦於以下問題:C# NLogXmlElement.Elements方法的具體用法?C# NLogXmlElement.Elements怎麽用?C# NLogXmlElement.Elements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NLog.Config.NLogXmlElement
的用法示例。
在下文中一共展示了NLogXmlElement.Elements方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ParseExtensionsElement
private void ParseExtensionsElement(NLogXmlElement extensionsElement, string baseDirectory)
{
extensionsElement.AssertName("extensions");
foreach (var addElement in extensionsElement.Elements("add"))
{
string prefix = addElement.GetOptionalAttribute("prefix", null);
if (prefix != null)
{
prefix = prefix + ".";
}
string type = StripOptionalNamespacePrefix(addElement.GetOptionalAttribute("type", null));
if (type != null)
{
this.ConfigurationItemFactory.RegisterType(Type.GetType(type, true), prefix);
}
string assemblyFile = addElement.GetOptionalAttribute("assemblyFile", null);
if (assemblyFile != null)
{
try
{
#if SILVERLIGHT && !WINDOWS_PHONE
var si = Application.GetResourceStream(new Uri(assemblyFile, UriKind.Relative));
var assemblyPart = new AssemblyPart();
Assembly asm = assemblyPart.Load(si.Stream);
#else
string fullFileName = Path.Combine(baseDirectory, assemblyFile);
InternalLogger.Info("Loading assembly file: {0}", fullFileName);
Assembly asm = Assembly.LoadFrom(fullFileName);
#endif
this.ConfigurationItemFactory.RegisterItemsFromAssembly(asm, prefix);
}
catch (Exception exception)
{
if (exception.MustBeRethrown())
{
throw;
}
InternalLogger.Error("Error loading extensions: {0}", exception);
if (LogManager.ThrowExceptions)
{
throw new NLogConfigurationException("Error loading extensions: " + assemblyFile, exception);
}
}
continue;
}
string assemblyName = addElement.GetOptionalAttribute("assembly", null);
if (assemblyName != null)
{
try
{
InternalLogger.Info("Loading assembly name: {0}", assemblyName);
#if SILVERLIGHT && !WINDOWS_PHONE
var si = Application.GetResourceStream(new Uri(assemblyName + ".dll", UriKind.Relative));
var assemblyPart = new AssemblyPart();
Assembly asm = assemblyPart.Load(si.Stream);
#else
Assembly asm = Assembly.Load(assemblyName);
#endif
this.ConfigurationItemFactory.RegisterItemsFromAssembly(asm, prefix);
}
catch (Exception exception)
{
if (exception.MustBeRethrown())
{
throw;
}
InternalLogger.Error("Error loading extensions: {0}", exception);
if (LogManager.ThrowExceptions)
{
throw new NLogConfigurationException("Error loading extensions: " + assemblyName, exception);
}
}
continue;
}
}
}
示例2: ParseConfigurationElement
/// <summary>
/// Parse {configuration} xml element.
/// </summary>
/// <param name="configurationElement"></param>
/// <param name="filePath">path to config file.</param>
/// <param name="autoReloadDefault">The default value for the autoReload option.</param>
private void ParseConfigurationElement(NLogXmlElement configurationElement, string filePath, bool autoReloadDefault)
{
InternalLogger.Trace("ParseConfigurationElement");
configurationElement.AssertName("configuration");
foreach (var el in configurationElement.Elements("nlog"))
{
this.ParseNLogElement(el, filePath, autoReloadDefault);
}
}
示例3: ParseRulesElement
/// <summary>
/// Parse {Rules} xml element
/// </summary>
/// <param name="rulesElement"></param>
/// <param name="rulesCollection">Rules are added to this parameter.</param>
private void ParseRulesElement(NLogXmlElement rulesElement, IList<LoggingRule> rulesCollection)
{
InternalLogger.Trace("ParseRulesElement");
rulesElement.AssertName("rules");
foreach (var loggerElement in rulesElement.Elements("logger"))
{
this.ParseLoggerElement(loggerElement, rulesCollection);
}
}
示例4: ParseConfigurationElement
private void ParseConfigurationElement(NLogXmlElement configurationElement, string baseDirectory)
{
InternalLogger.Trace("ParseConfigurationElement");
configurationElement.AssertName("configuration");
foreach (var el in configurationElement.Elements("nlog"))
{
this.ParseNLogElement(el, baseDirectory);
}
}