#define DEBUG using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Text; using Common.Logging; using Common.Logging.Configuration; using Common.Logging.Factory; using Common.Logging.Simple; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyFileVersion("3.4.0.0")] [assembly: TargetFramework(".NETStandard,Version=v1.3")] [assembly: CLSCompliant(true)] [assembly: AssemblyConfiguration("portable; release")] [assembly: AssemblyInformationalVersion("3.4.1; portable; release")] [assembly: AssemblyCompany("http://netcommon.sourceforge.net/")] [assembly: AssemblyCopyright("Copyright 2006-2011 the Common Infrastructure Libraries Team.")] [assembly: AssemblyTrademark("Apache License, Version 2.0")] [assembly: AssemblyDelaySign(false)] [assembly: AssemblyProduct("Common Logging Framework")] [assembly: SecurityTransparent] [assembly: AssemblyVersion("3.4.1.0")] [assembly: TypeForwardedTo(typeof(FormatMessageHandler))] [assembly: TypeForwardedTo(typeof(IConfigurationReader))] [assembly: TypeForwardedTo(typeof(ILog))] [assembly: TypeForwardedTo(typeof(ILoggerFactoryAdapter))] [assembly: TypeForwardedTo(typeof(ILogManager))] [assembly: TypeForwardedTo(typeof(IVariablesContext))] [assembly: TypeForwardedTo(typeof(LogLevel))] [AttributeUsage(AttributeTargets.All)] internal class CoverageExcludeAttribute : Attribute { } namespace Common.Logging { public class ConfigurationException : Exception { public ConfigurationException() { } public ConfigurationException(string message) : base(message) { } public ConfigurationException(string message, Exception rootCause) : base(message, rootCause) { } } public class LogManager : ILogManager { private static IConfigurationReader _configurationReader; private static ILoggerFactoryAdapter _adapter; private static readonly object _loadLock; private static Func _getCallingMethod; public static string COMMON_LOGGING_SECTION => "common/logging"; string ILogManager.COMMON_LOGGING_SECTION => COMMON_LOGGING_SECTION; public static IConfigurationReader ConfigurationReader => _configurationReader; IConfigurationReader ILogManager.ConfigurationReader => ConfigurationReader; public static ILoggerFactoryAdapter Adapter { get { if (_adapter == null) { lock (_loadLock) { if (_adapter == null) { _adapter = BuildLoggerFactoryAdapter(); } } } return _adapter; } set { if (value == null) { throw new ArgumentNullException("Adapter"); } lock (_loadLock) { _adapter = value; } } } ILoggerFactoryAdapter ILogManager.Adapter { get { return Adapter; } set { Adapter = value; } } static LogManager() { _loadLock = new object(); Reset(); } public static void Reset() { Reset((IConfigurationReader)(object)new DefaultConfigurationReader()); } void ILogManager.Reset() { Reset(); } public static void Reset(IConfigurationReader reader) { lock (_loadLock) { if (reader == null) { throw new ArgumentNullException("reader"); } _configurationReader = reader; _adapter = null; } } void ILogManager.Reset(IConfigurationReader reader) { Reset(reader); } public static void Configure(LogConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } Reset((IConfigurationReader)(object)new LogConfigurationReader(configuration)); } [MethodImpl(MethodImplOptions.NoInlining)] [Obsolete("Null-Reference Exception when dealing with Dynamic Types, Prefer instead one of the LogManager.GetLogger(...) variants.")] public static ILog GetCurrentClassLogger() { MethodBase callingMethod = GetCallingMethod(); Type declaringType = callingMethod.DeclaringType; return Adapter.GetLogger(declaringType); } [MethodImpl(MethodImplOptions.NoInlining)] [Obsolete("Null-Reference Exception when dealing with Dynamic Types, Prefer instead one of the LogManager.GetLogger(...) variants.")] ILog ILogManager.GetCurrentClassLogger() { return GetCurrentClassLogger(); } [MethodImpl(MethodImplOptions.NoInlining)] private static MethodBase GetCallingMethod() { Func getCallingMethod = _getCallingMethod; if (getCallingMethod == null) { lock (_loadLock) { if (_getCallingMethod == null) { _getCallingMethod = CreateGetClassNameFunction(); } getCallingMethod = _getCallingMethod; } } return getCallingMethod(); } private static Func CreateGetClassNameFunction() { Type type = Type.GetType("System.Diagnostics.StackFrame"); if ((object)type == null) { throw new PlatformNotSupportedException("CreateGetClassNameFunction is only supported on platforms where System.Diagnostics.StackFrame exist"); } ConstructorInfo constructor = TypeExtensions.GetConstructor(type, new Type[1] { typeof(int) }); MethodInfo method = TypeExtensions.GetMethod(type, "GetMethod"); if ((object)constructor == null) { throw new PlatformNotSupportedException("StackFrame(int skipFrames) constructor not present"); } if ((object)method == null) { throw new PlatformNotSupportedException("StackFrame.GetMethod() not present"); } NewExpression instance = Expression.New(constructor, Expression.Constant(3)); MethodCallExpression body = Expression.Call(instance, method); Expression> expression = Expression.Lambda>(body, Array.Empty()); MethodInfo method2 = TypeExtensions.GetMethod(expression.GetType(), "Compile", new Type[0]); return (Func)method2.Invoke(expression, null); } public static ILog GetLogger() { return Adapter.GetLogger(typeof(T)); } ILog ILogManager.GetLogger() { return GetLogger(); } public static ILog GetLogger(Type type) { return Adapter.GetLogger(type); } ILog ILogManager.GetLogger(Type type) { return GetLogger(type); } public static ILog GetLogger(string key) { return Adapter.GetLogger(key); } ILog ILogManager.GetLogger(string key) { return GetLogger(key); } private static ILoggerFactoryAdapter BuildLoggerFactoryAdapter() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown object sectionResult = null; ArgUtils.Guard(delegate { sectionResult = ConfigurationReader.GetSection(COMMON_LOGGING_SECTION); }, "Failed obtaining configuration for Common.Logging from configuration section 'common/logging'."); if (sectionResult == null) { string text = (((object)((object)ConfigurationReader).GetType() == typeof(DefaultConfigurationReader)) ? $"no configuration section <{COMMON_LOGGING_SECTION}> found - suppressing logging output" : $"Custom ConfigurationReader '{((object)ConfigurationReader).GetType().FullName}' returned - suppressing logging output"); return (ILoggerFactoryAdapter)(object)new NoOpLoggerFactoryAdapter(); } if (sectionResult is ILoggerFactoryAdapter) { return (ILoggerFactoryAdapter)sectionResult; } ArgUtils.Guard(delegate { ArgUtils.AssertIsAssignable("sectionResult", sectionResult.GetType()); }, "ConfigurationReader {0} returned unknown settings instance of type {1}", ((object)ConfigurationReader).GetType().FullName, sectionResult.GetType().FullName); ILoggerFactoryAdapter adapter = null; ArgUtils.Guard(delegate { adapter = BuildLoggerFactoryAdapterFromLogSettings((LogSetting)sectionResult); }, "Failed creating LoggerFactoryAdapter from settings"); return adapter; } public static ILoggerFactoryAdapter BuildLoggerFactoryAdapterFromLogSettings(LogSetting setting) { ArgUtils.AssertNotNull("setting", setting); ILoggerFactoryAdapter adapter = null; ArgUtils.Guard(delegate { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if (setting.Properties != null && setting.Properties.Count > 0) { object[] args = new object[1] { setting.Properties }; adapter = (ILoggerFactoryAdapter)Activator.CreateInstance(setting.FactoryAdapterType, args); } else { adapter = (ILoggerFactoryAdapter)Activator.CreateInstance(setting.FactoryAdapterType); } }, "Unable to create instance of type {0}. Possible explanation is lack of zero arg and single arg Common.Logging.Configuration.NameValueCollection constructors", setting.FactoryAdapterType.FullName); ArgUtils.AssertNotNull("adapter", adapter, "Activator.CreateInstance() returned ", Array.Empty()); return adapter; } } } namespace Common.Logging.Simple { public abstract class AbstractSimpleLogger : AbstractLogger { private readonly string _name; private readonly bool _showLevel; private readonly bool _showDateTime; private readonly bool _showLogName; private LogLevel _currentLogLevel; private readonly string _dateTimeFormat; private readonly bool _hasDateTimeFormat; [CoverageExclude] public string Name => _name; [CoverageExclude] public bool ShowLevel => _showLevel; [CoverageExclude] public bool ShowDateTime => _showDateTime; [CoverageExclude] public bool ShowLogName => _showLogName; [CoverageExclude] public LogLevel CurrentLogLevel { get { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) return _currentLogLevel; } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _currentLogLevel = value; } } [CoverageExclude] public string DateTimeFormat => _dateTimeFormat; [CoverageExclude] public bool HasDateTimeFormat => _hasDateTimeFormat; public override bool IsTraceEnabled => IsLevelEnabled((LogLevel)1); public override bool IsDebugEnabled => IsLevelEnabled((LogLevel)2); public override bool IsInfoEnabled => IsLevelEnabled((LogLevel)4); public override bool IsWarnEnabled => IsLevelEnabled((LogLevel)8); public override bool IsErrorEnabled => IsLevelEnabled((LogLevel)16); public override bool IsFatalEnabled => IsLevelEnabled((LogLevel)32); public AbstractSimpleLogger(string logName, LogLevel logLevel, bool showlevel, bool showDateTime, bool showLogName, string dateTimeFormat) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) _name = logName; _currentLogLevel = logLevel; _showLevel = showlevel; _showDateTime = showDateTime; _showLogName = showLogName; _dateTimeFormat = dateTimeFormat; _hasDateTimeFormat = !string.IsNullOrEmpty(_dateTimeFormat); } protected unsafe virtual void FormatOutput(StringBuilder stringBuilder, LogLevel level, object message, Exception e) { if (stringBuilder == null) { throw new ArgumentNullException("stringBuilder"); } if (_showDateTime) { if (_hasDateTimeFormat) { stringBuilder.Append(DateTime.Now.ToString(_dateTimeFormat, CultureInfo.InvariantCulture)); } else { stringBuilder.Append(DateTime.Now); } stringBuilder.Append(" "); } if (_showLevel) { stringBuilder.Append(("[" + ((object)(*(LogLevel*)(&level))/*cast due to .constrained prefix*/).ToString().ToUpper() + "]").PadRight(8)); } if (_showLogName) { stringBuilder.Append(_name).Append(" - "); } stringBuilder.Append(message); if (e != null) { stringBuilder.Append(Environment.NewLine).Append(ExceptionFormatter.Format(e)); } } protected virtual bool IsLevelEnabled(LogLevel level) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Expected I4, but got Unknown //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected I4, but got Unknown int num = (int)level; int num2 = (int)_currentLogLevel; return num >= num2; } } public abstract class AbstractSimpleLoggerFactoryAdapter : AbstractCachingLoggerFactoryAdapter { private LogLevel _level; private bool _showLevel; private bool _showDateTime; private bool _showLogName; private string _dateTimeFormat; [CoverageExclude] public LogLevel Level { get { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) return _level; } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _level = value; } } [CoverageExclude] public bool ShowLevel { get { return _showLevel; } set { _showLevel = value; } } [CoverageExclude] public bool ShowDateTime { get { return _showDateTime; } set { _showDateTime = value; } } [CoverageExclude] public bool ShowLogName { get { return _showLogName; } set { _showLogName = value; } } [CoverageExclude] public string DateTimeFormat { get { return _dateTimeFormat; } set { _dateTimeFormat = value; } } protected AbstractSimpleLoggerFactoryAdapter(NameValueCollection properties) : this(ArgUtils.TryParseEnum((LogLevel)0, ArgUtils.GetValue(properties, "level")), ArgUtils.TryParse(defaultValue: true, ArgUtils.GetValue(properties, "showDateTime")), ArgUtils.TryParse(defaultValue: true, ArgUtils.GetValue(properties, "showLogName")), ArgUtils.TryParse(defaultValue: true, ArgUtils.GetValue(properties, "showLevel")), ArgUtils.GetValue(properties, "dateTimeFormat", string.Empty)) { }//IL_000d: Unknown result type (might be due to invalid IL or missing references) protected AbstractSimpleLoggerFactoryAdapter(LogLevel level, bool showDateTime, bool showLogName, bool showLevel, string dateTimeFormat) : base(caseSensitiveLoggerCache: true) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) _level = level; _showDateTime = showDateTime; _showLogName = showLogName; _showLevel = showLevel; _dateTimeFormat = dateTimeFormat ?? string.Empty; } protected override ILog CreateLogger(string name) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) return CreateLogger(name, _level, _showLevel, _showDateTime, _showLogName, _dateTimeFormat); } protected abstract ILog CreateLogger(string name, LogLevel level, bool showLevel, bool showDateTime, bool showLogName, string dateTimeFormat); } public class CapturingLogger : AbstractSimpleLogger { public readonly CapturingLoggerFactoryAdapter Owner; private volatile CapturingLoggerEvent _lastEvent; public readonly IList LoggerEvents = new List(); public CapturingLoggerEvent LastEvent => _lastEvent; public void Clear() { lock (LoggerEvents) { ClearLastEvent(); LoggerEvents.Clear(); } } public void ClearLastEvent() { _lastEvent = null; } public virtual void AddEvent(CapturingLoggerEvent loggerEvent) { _lastEvent = loggerEvent; lock (LoggerEvents) { LoggerEvents.Add(loggerEvent); } Owner.AddEvent(LastEvent); } public CapturingLogger(CapturingLoggerFactoryAdapter owner, string logName) : base(logName, (LogLevel)0, showlevel: true, showDateTime: true, showLogName: true, null) { ArgUtils.AssertNotNull("owner", owner); Owner = owner; } protected override void WriteInternal(LogLevel level, object message, Exception exception) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) CapturingLoggerEvent loggerEvent = new CapturingLoggerEvent(this, level, message, exception); AddEvent(loggerEvent); } } public class CapturingLoggerEvent { public readonly CapturingLogger Source; public readonly LogLevel Level; public readonly object MessageObject; public readonly Exception Exception; public string RenderedMessage => MessageObject.ToString(); public CapturingLoggerEvent(CapturingLogger source, LogLevel level, object messageObject, Exception exception) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Source = source; Level = level; MessageObject = messageObject; Exception = exception; } } public class CapturingLoggerFactoryAdapter : ILoggerFactoryAdapter { private readonly Dictionary _cachedLoggers = new Dictionary(StringComparer.OrdinalIgnoreCase); private volatile CapturingLoggerEvent _lastEvent; public readonly IList LoggerEvents = new List(); public CapturingLoggerEvent LastEvent => _lastEvent; public void Clear() { lock (LoggerEvents) { ClearLastEvent(); LoggerEvents.Clear(); } } public void ClearLastEvent() { _lastEvent = null; } public virtual void AddEvent(CapturingLoggerEvent loggerEvent) { _lastEvent = loggerEvent; lock (LoggerEvents) { LoggerEvents.Add(loggerEvent); } } public ILog GetLogger(Type type) { return GetLogger(type.FullName); } public ILog GetLogger(string name) { if (!_cachedLoggers.TryGetValue(name, out var value)) { lock (((ICollection)_cachedLoggers).SyncRoot) { if (!_cachedLoggers.TryGetValue(name, out value)) { value = (ILog)(object)new CapturingLogger(this, name); _cachedLoggers[name] = value; } } } return value; } } public class DebugOutLogger : AbstractSimpleLogger { public DebugOutLogger(string logName, LogLevel logLevel, bool showLevel, bool showDateTime, bool showLogName, string dateTimeFormat) : base(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat) { }//IL_0002: Unknown result type (might be due to invalid IL or missing references) protected override void WriteInternal(LogLevel level, object message, Exception e) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); FormatOutput(stringBuilder, level, message, e); System.Diagnostics.Debug.WriteLine(stringBuilder.ToString()); } } public class DebugLoggerFactoryAdapter : AbstractSimpleLoggerFactoryAdapter { public DebugLoggerFactoryAdapter() : base(null) { } public DebugLoggerFactoryAdapter(NameValueCollection properties) : base(properties) { } public DebugLoggerFactoryAdapter(LogLevel level, bool showDateTime, bool showLogName, bool showLevel, string dateTimeFormat) : base(level, showDateTime, showLogName, showLevel, dateTimeFormat) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) protected override ILog CreateLogger(string name, LogLevel level, bool showLevel, bool showDateTime, bool showLogName, string dateTimeFormat) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return (ILog)(object)new DebugOutLogger(name, level, showLevel, showDateTime, showLogName, dateTimeFormat); } } internal static class ExceptionFormatter { private const string STANDARD_DELIMETER = "================================================================================\r\n"; private const string INNERMOST_DELIMETER = "=======================================================(inner most exception)===\r\n"; internal static string Format(Exception exception) { return Format(exception, CultureInfo.InvariantCulture); } internal static string Format(Exception exception, IFormatProvider formatProvider) { if (exception == null) { return null; } Stack stack = new Stack(); for (Exception ex = exception; ex != null; ex = ex.InnerException) { stack.Push(ex); } StringBuilder stringBuilder = new StringBuilder(); int num = 1; while (stack.Count > 0) { Exception ex = stack.Pop(); FormatSingleException(formatProvider, stringBuilder, ex, num); num++; } return stringBuilder.ToString(); } private static void FormatSingleException(IFormatProvider formatProvider, StringBuilder sb, Exception exception, int exceptionIndex) { OutputHeader(formatProvider, sb, exception, exceptionIndex); OutputDetails(formatProvider, sb, exception); OutputMessage(formatProvider, sb, exception); OutputProperties(formatProvider, sb, exception); OutputData(formatProvider, sb, exception); OutputStackTrace(formatProvider, sb, exception); sb.Append("================================================================================\r\n"); } private static void OutputHeader(IFormatProvider formatProvider, StringBuilder sb, Exception exception, int exceptionIndex) { sb.Append((exceptionIndex == 1) ? "=======================================================(inner most exception)===\r\n" : "================================================================================\r\n"); sb.AppendFormat(formatProvider, " ({0}) {1}\r\n", exceptionIndex, ((object)exception).GetType().FullName); sb.Append("================================================================================\r\n"); } private static void OutputDetails(IFormatProvider formatProvider, StringBuilder sb, Exception exception) { } private static void OutputMessage(IFormatProvider formatProvider, StringBuilder sb, Exception exception) { sb.AppendFormat(formatProvider, "\r\nMessage:\r\n\"{0}\"\r\n", exception.Message); } private static void OutputProperties(IFormatProvider formatProvider, StringBuilder sb, Exception exception) { PropertyInfo[] properties = TypeExtensions.GetProperties(((object)exception).GetType(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); bool flag = true; PropertyInfo[] array = properties; foreach (PropertyInfo propertyInfo in array) { if ((object)propertyInfo.DeclaringType == typeof(Exception) || propertyInfo.Name == "Message") { continue; } if (flag) { flag = false; sb.Append("\r\nProperties:\r\n"); } object obj = ""; if (propertyInfo.CanRead && propertyInfo.GetIndexParameters().Length == 0) { obj = propertyInfo.GetValue(exception, null); } IEnumerable enumerable = obj as IEnumerable; string name = propertyInfo.PropertyType.Name; if (enumerable == null || obj is string) { sb.AppendFormat(formatProvider, " {0}.{1} = \"{2}\"\r\n", name, propertyInfo.Name, obj); continue; } sb.AppendFormat(formatProvider, " {0}.{1} = {{\r\n", name, propertyInfo.Name); foreach (object item in enumerable) { sb.AppendFormat(" \"{0}\",\r\n", (item != null) ? item.ToString() : ""); } sb.Append(" }\r\n"); } } private static void OutputData(IFormatProvider formatProvider, StringBuilder sb, Exception exception) { if (exception.Data.Count <= 0) { return; } sb.Append("\r\nData:\r\n"); foreach (DictionaryEntry datum in exception.Data) { sb.AppendFormat(formatProvider, "{0} = \"{1}\"\r\n", datum.Key, datum.Value); } } private static void OutputStackTrace(IFormatProvider formatProvider, StringBuilder sb, Exception exception) { sb.AppendFormat(formatProvider, "\r\nStack Trace:\r\n{0}\r\n", exception.StackTrace); } } [CoverageExclude] public sealed class NoOpLogger : ILog { public bool IsTraceEnabled => false; public bool IsDebugEnabled => false; public bool IsInfoEnabled => false; public bool IsWarnEnabled => false; public bool IsErrorEnabled => false; public bool IsFatalEnabled => false; public IVariablesContext GlobalVariablesContext => (IVariablesContext)(object)new NoOpVariablesContext(); public IVariablesContext ThreadVariablesContext => (IVariablesContext)(object)new NoOpVariablesContext(); public INestedVariablesContext NestedThreadVariablesContext => (INestedVariablesContext)(object)new NoOpNestedVariablesContext(); public void Trace(object message) { } public void Trace(object message, Exception e) { } public void TraceFormat(string format, params object[] args) { } public void TraceFormat(string format, Exception exception, params object[] args) { } public void TraceFormat(IFormatProvider formatProvider, string format, params object[] args) { } public void TraceFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { } public void Trace(Action formatMessageCallback) { } public void Trace(Action formatMessageCallback, Exception exception) { } public void Trace(IFormatProvider formatProvider, Action formatMessageCallback) { } public void Trace(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { } public void Debug(object message) { } public void Debug(object message, Exception e) { } public void DebugFormat(string format, params object[] args) { } public void DebugFormat(string format, Exception exception, params object[] args) { } public void DebugFormat(IFormatProvider formatProvider, string format, params object[] args) { } public void DebugFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { } public void Debug(Action formatMessageCallback) { } public void Debug(Action formatMessageCallback, Exception exception) { } public void Debug(IFormatProvider formatProvider, Action formatMessageCallback) { } public void Debug(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { } public void Info(object message) { } public void Info(object message, Exception e) { } public void InfoFormat(string format, params object[] args) { } public void InfoFormat(string format, Exception exception, params object[] args) { } public void InfoFormat(IFormatProvider formatProvider, string format, params object[] args) { } public void InfoFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { } public void Info(Action formatMessageCallback) { } public void Info(Action formatMessageCallback, Exception exception) { } public void Info(IFormatProvider formatProvider, Action formatMessageCallback) { } public void Info(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { } public void Warn(object message) { } public void Warn(object message, Exception e) { } public void WarnFormat(string format, params object[] args) { } public void WarnFormat(string format, Exception exception, params object[] args) { } public void WarnFormat(IFormatProvider formatProvider, string format, params object[] args) { } public void WarnFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { } public void Warn(Action formatMessageCallback) { } public void Warn(Action formatMessageCallback, Exception exception) { } public void Warn(IFormatProvider formatProvider, Action formatMessageCallback) { } public void Warn(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { } public void Error(object message) { } public void Error(object message, Exception e) { } public void ErrorFormat(string format, params object[] args) { } public void ErrorFormat(string format, Exception exception, params object[] args) { } public void ErrorFormat(IFormatProvider formatProvider, string format, params object[] args) { } public void ErrorFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { } public void Error(Action formatMessageCallback) { } public void Error(Action formatMessageCallback, Exception exception) { } public void Error(IFormatProvider formatProvider, Action formatMessageCallback) { } public void Error(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { } public void Fatal(object message) { } public void Fatal(object message, Exception e) { } public void FatalFormat(string format, params object[] args) { } public void FatalFormat(string format, Exception exception, params object[] args) { } public void FatalFormat(IFormatProvider formatProvider, string format, params object[] args) { } public void FatalFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { } public void Fatal(Action formatMessageCallback) { } public void Fatal(Action formatMessageCallback, Exception exception) { } public void Fatal(IFormatProvider formatProvider, Action formatMessageCallback) { } public void Fatal(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { } } public sealed class NoOpLoggerFactoryAdapter : ILoggerFactoryAdapter { private static readonly ILog s_nopLogger = (ILog)(object)new NoOpLogger(); public NoOpLoggerFactoryAdapter() { } public NoOpLoggerFactoryAdapter(NameValueCollection properties) { } public ILog GetLogger(Type type) { return s_nopLogger; } ILog ILoggerFactoryAdapter.GetLogger(string key) { return s_nopLogger; } } public class NoOpNestedVariablesContext : INestedVariablesContext { private class NoOpDisposable : IDisposable { public void Dispose() { } } public bool HasItems { get; private set; } public IDisposable Push(string text) { return new NoOpDisposable(); } public string Pop() { return null; } public void Clear() { } } public class NoOpVariablesContext : IVariablesContext { public void Set(string key, object value) { } public object Get(string key) { return null; } public bool Contains(string key) { return false; } public void Remove(string key) { } public void Clear() { } } } namespace Common.Logging.Factory { public abstract class AbstractCachingLoggerFactoryAdapter : ILoggerFactoryAdapter { private readonly Dictionary _cachedLoggers; protected AbstractCachingLoggerFactoryAdapter() : this(caseSensitiveLoggerCache: true) { } protected AbstractCachingLoggerFactoryAdapter(bool caseSensitiveLoggerCache) { _cachedLoggers = (caseSensitiveLoggerCache ? new Dictionary() : new Dictionary(StringComparer.OrdinalIgnoreCase)); } protected void ClearLoggerCache() { lock (_cachedLoggers) { _cachedLoggers.Clear(); } } protected abstract ILog CreateLogger(string name); public ILog GetLogger(Type type) { return GetLoggerInternal(type.FullName); } public ILog GetLogger(string key) { return GetLoggerInternal(key); } private ILog GetLoggerInternal(string key) { if (!_cachedLoggers.TryGetValue(key, out var value)) { lock (_cachedLoggers) { if (!_cachedLoggers.TryGetValue(key, out value)) { value = CreateLogger(key); if (value == null) { throw new ArgumentException($"{GetType().FullName} returned null on creating logger instance for key {key}"); } _cachedLoggers.Add(key, value); } } } return value; } } public abstract class AbstractLogger : ILog { [CLSCompliant(false)] protected class FormatMessageCallbackFormattedMessage { protected volatile string cachedMessage; protected readonly IFormatProvider formatProvider; protected readonly Action formatMessageCallback; protected volatile string cachedFormat; protected volatile object[] cachedArguments; public FormatMessageCallbackFormattedMessage(Action formatMessageCallback) { this.formatMessageCallback = formatMessageCallback; } public FormatMessageCallbackFormattedMessage(IFormatProvider formatProvider, Action formatMessageCallback) { this.formatProvider = formatProvider; this.formatMessageCallback = formatMessageCallback; } public override string ToString() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown if (cachedMessage == null && formatMessageCallback != null) { formatMessageCallback(new FormatMessageHandler(FormatMessage)); } return cachedMessage; } [StringFormatMethod("format")] protected string FormatMessage(string format, params object[] args) { if (args.Length != 0 && formatProvider != null) { cachedMessage = string.Format(formatProvider, format, args); } else if (args.Length != 0) { cachedMessage = string.Format(format, args); } else if (formatProvider != null) { cachedMessage = string.Format(formatProvider, format); } else { cachedMessage = format; } cachedFormat = format; cachedArguments = args; return cachedMessage; } } protected class StringFormatFormattedMessage { private volatile string cachedMessage; private readonly IFormatProvider FormatProvider; private readonly string Message; private readonly object[] Args; [StringFormatMethod("message")] public StringFormatFormattedMessage(IFormatProvider formatProvider, string message, params object[] args) { FormatProvider = formatProvider; Message = message; Args = args; } public override string ToString() { if (cachedMessage == null && Message != null) { cachedMessage = string.Format(FormatProvider, Message, Args); } return cachedMessage; } } protected delegate void WriteHandler(LogLevel level, object message, Exception exception); private readonly WriteHandler Write; public abstract bool IsTraceEnabled { get; } public abstract bool IsDebugEnabled { get; } public abstract bool IsInfoEnabled { get; } public abstract bool IsWarnEnabled { get; } public abstract bool IsErrorEnabled { get; } public abstract bool IsFatalEnabled { get; } public virtual IVariablesContext GlobalVariablesContext => (IVariablesContext)(object)new NoOpVariablesContext(); public virtual IVariablesContext ThreadVariablesContext => (IVariablesContext)(object)new NoOpVariablesContext(); public virtual INestedVariablesContext NestedThreadVariablesContext => (INestedVariablesContext)(object)new NoOpNestedVariablesContext(); protected AbstractLogger() { Write = GetWriteHandler(); if (Write == null) { Write = WriteInternal; } } protected virtual WriteHandler GetWriteHandler() { return null; } protected abstract void WriteInternal(LogLevel level, object message, Exception exception); public virtual void Trace(object message) { if (IsTraceEnabled) { Write((LogLevel)1, message, null); } } public virtual void Trace(object message, Exception exception) { if (IsTraceEnabled) { Write((LogLevel)1, message, exception); } } [StringFormatMethod("format")] public virtual void TraceFormat(IFormatProvider formatProvider, string format, params object[] args) { if (IsTraceEnabled) { Write((LogLevel)1, new StringFormatFormattedMessage(formatProvider, format, args), null); } } [StringFormatMethod("format")] public virtual void TraceFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { if (IsTraceEnabled) { Write((LogLevel)1, new StringFormatFormattedMessage(formatProvider, format, args), exception); } } [StringFormatMethod("format")] public virtual void TraceFormat(string format, params object[] args) { if (IsTraceEnabled) { Write((LogLevel)1, new StringFormatFormattedMessage(null, format, args), null); } } [StringFormatMethod("format")] public virtual void TraceFormat(string format, Exception exception, params object[] args) { if (IsTraceEnabled) { Write((LogLevel)1, new StringFormatFormattedMessage(null, format, args), exception); } } public virtual void Trace(Action formatMessageCallback) { if (IsTraceEnabled) { Write((LogLevel)1, new FormatMessageCallbackFormattedMessage(formatMessageCallback), null); } } public virtual void Trace(Action formatMessageCallback, Exception exception) { if (IsTraceEnabled) { Write((LogLevel)1, new FormatMessageCallbackFormattedMessage(formatMessageCallback), exception); } } public virtual void Trace(IFormatProvider formatProvider, Action formatMessageCallback) { if (IsTraceEnabled) { Write((LogLevel)1, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), null); } } public virtual void Trace(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { if (IsTraceEnabled) { Write((LogLevel)1, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), exception); } } public virtual void Debug(object message) { if (IsDebugEnabled) { Write((LogLevel)2, message, null); } } public virtual void Debug(object message, Exception exception) { if (IsDebugEnabled) { Write((LogLevel)2, message, exception); } } [StringFormatMethod("format")] public virtual void DebugFormat(IFormatProvider formatProvider, string format, params object[] args) { if (IsDebugEnabled) { Write((LogLevel)2, new StringFormatFormattedMessage(formatProvider, format, args), null); } } [StringFormatMethod("format")] public virtual void DebugFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { if (IsDebugEnabled) { Write((LogLevel)2, new StringFormatFormattedMessage(formatProvider, format, args), exception); } } [StringFormatMethod("format")] public virtual void DebugFormat(string format, params object[] args) { if (IsDebugEnabled) { Write((LogLevel)2, new StringFormatFormattedMessage(null, format, args), null); } } [StringFormatMethod("format")] public virtual void DebugFormat(string format, Exception exception, params object[] args) { if (IsDebugEnabled) { Write((LogLevel)2, new StringFormatFormattedMessage(null, format, args), exception); } } public virtual void Debug(Action formatMessageCallback) { if (IsDebugEnabled) { Write((LogLevel)2, new FormatMessageCallbackFormattedMessage(formatMessageCallback), null); } } public virtual void Debug(Action formatMessageCallback, Exception exception) { if (IsDebugEnabled) { Write((LogLevel)2, new FormatMessageCallbackFormattedMessage(formatMessageCallback), exception); } } public virtual void Debug(IFormatProvider formatProvider, Action formatMessageCallback) { if (IsDebugEnabled) { Write((LogLevel)2, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), null); } } public virtual void Debug(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { if (IsDebugEnabled) { Write((LogLevel)2, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), exception); } } public virtual void Info(object message) { if (IsInfoEnabled) { Write((LogLevel)4, message, null); } } public virtual void Info(object message, Exception exception) { if (IsInfoEnabled) { Write((LogLevel)4, message, exception); } } [StringFormatMethod("format")] public virtual void InfoFormat(IFormatProvider formatProvider, string format, params object[] args) { if (IsInfoEnabled) { Write((LogLevel)4, new StringFormatFormattedMessage(formatProvider, format, args), null); } } [StringFormatMethod("format")] public virtual void InfoFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { if (IsInfoEnabled) { Write((LogLevel)4, new StringFormatFormattedMessage(formatProvider, format, args), exception); } } [StringFormatMethod("format")] public virtual void InfoFormat(string format, params object[] args) { if (IsInfoEnabled) { Write((LogLevel)4, new StringFormatFormattedMessage(null, format, args), null); } } [StringFormatMethod("format")] public virtual void InfoFormat(string format, Exception exception, params object[] args) { if (IsInfoEnabled) { Write((LogLevel)4, new StringFormatFormattedMessage(null, format, args), exception); } } public virtual void Info(Action formatMessageCallback) { if (IsInfoEnabled) { Write((LogLevel)4, new FormatMessageCallbackFormattedMessage(formatMessageCallback), null); } } public virtual void Info(Action formatMessageCallback, Exception exception) { if (IsInfoEnabled) { Write((LogLevel)4, new FormatMessageCallbackFormattedMessage(formatMessageCallback), exception); } } public virtual void Info(IFormatProvider formatProvider, Action formatMessageCallback) { if (IsInfoEnabled) { Write((LogLevel)4, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), null); } } public virtual void Info(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { if (IsInfoEnabled) { Write((LogLevel)4, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), exception); } } public virtual void Warn(object message) { if (IsWarnEnabled) { Write((LogLevel)8, message, null); } } public virtual void Warn(object message, Exception exception) { if (IsWarnEnabled) { Write((LogLevel)8, message, exception); } } [StringFormatMethod("format")] public virtual void WarnFormat(IFormatProvider formatProvider, string format, params object[] args) { if (IsWarnEnabled) { Write((LogLevel)8, new StringFormatFormattedMessage(formatProvider, format, args), null); } } [StringFormatMethod("format")] public virtual void WarnFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { if (IsWarnEnabled) { Write((LogLevel)8, new StringFormatFormattedMessage(formatProvider, format, args), exception); } } [StringFormatMethod("format")] public virtual void WarnFormat(string format, params object[] args) { if (IsWarnEnabled) { Write((LogLevel)8, new StringFormatFormattedMessage(null, format, args), null); } } [StringFormatMethod("format")] public virtual void WarnFormat(string format, Exception exception, params object[] args) { if (IsWarnEnabled) { Write((LogLevel)8, new StringFormatFormattedMessage(null, format, args), exception); } } public virtual void Warn(Action formatMessageCallback) { if (IsWarnEnabled) { Write((LogLevel)8, new FormatMessageCallbackFormattedMessage(formatMessageCallback), null); } } public virtual void Warn(Action formatMessageCallback, Exception exception) { if (IsWarnEnabled) { Write((LogLevel)8, new FormatMessageCallbackFormattedMessage(formatMessageCallback), exception); } } public virtual void Warn(IFormatProvider formatProvider, Action formatMessageCallback) { if (IsWarnEnabled) { Write((LogLevel)8, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), null); } } public virtual void Warn(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { if (IsWarnEnabled) { Write((LogLevel)8, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), exception); } } public virtual void Error(object message) { if (IsErrorEnabled) { Write((LogLevel)16, message, null); } } public virtual void Error(object message, Exception exception) { if (IsErrorEnabled) { Write((LogLevel)16, message, exception); } } [StringFormatMethod("format")] public virtual void ErrorFormat(IFormatProvider formatProvider, string format, params object[] args) { if (IsErrorEnabled) { Write((LogLevel)16, new StringFormatFormattedMessage(formatProvider, format, args), null); } } [StringFormatMethod("format")] public virtual void ErrorFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { if (IsErrorEnabled) { Write((LogLevel)16, new StringFormatFormattedMessage(formatProvider, format, args), exception); } } [StringFormatMethod("format")] public virtual void ErrorFormat(string format, params object[] args) { if (IsErrorEnabled) { Write((LogLevel)16, new StringFormatFormattedMessage(null, format, args), null); } } [StringFormatMethod("format")] public virtual void ErrorFormat(string format, Exception exception, params object[] args) { if (IsErrorEnabled) { Write((LogLevel)16, new StringFormatFormattedMessage(null, format, args), exception); } } public virtual void Error(Action formatMessageCallback) { if (IsErrorEnabled) { Write((LogLevel)16, new FormatMessageCallbackFormattedMessage(formatMessageCallback), null); } } public virtual void Error(Action formatMessageCallback, Exception exception) { if (IsErrorEnabled) { Write((LogLevel)16, new FormatMessageCallbackFormattedMessage(formatMessageCallback), exception); } } public virtual void Error(IFormatProvider formatProvider, Action formatMessageCallback) { if (IsErrorEnabled) { Write((LogLevel)16, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), null); } } public virtual void Error(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { if (IsErrorEnabled) { Write((LogLevel)16, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), exception); } } public virtual void Fatal(object message) { if (IsFatalEnabled) { Write((LogLevel)32, message, null); } } public virtual void Fatal(object message, Exception exception) { if (IsFatalEnabled) { Write((LogLevel)32, message, exception); } } [StringFormatMethod("format")] public virtual void FatalFormat(IFormatProvider formatProvider, string format, params object[] args) { if (IsFatalEnabled) { Write((LogLevel)32, new StringFormatFormattedMessage(formatProvider, format, args), null); } } [StringFormatMethod("format")] public virtual void FatalFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) { if (IsFatalEnabled) { Write((LogLevel)32, new StringFormatFormattedMessage(formatProvider, format, args), exception); } } [StringFormatMethod("format")] public virtual void FatalFormat(string format, params object[] args) { if (IsFatalEnabled) { Write((LogLevel)32, new StringFormatFormattedMessage(null, format, args), null); } } [StringFormatMethod("format")] public virtual void FatalFormat(string format, Exception exception, params object[] args) { if (IsFatalEnabled) { Write((LogLevel)32, new StringFormatFormattedMessage(null, format, args), exception); } } public virtual void Fatal(Action formatMessageCallback) { if (IsFatalEnabled) { Write((LogLevel)32, new FormatMessageCallbackFormattedMessage(formatMessageCallback), null); } } public virtual void Fatal(Action formatMessageCallback, Exception exception) { if (IsFatalEnabled) { Write((LogLevel)32, new FormatMessageCallbackFormattedMessage(formatMessageCallback), exception); } } public virtual void Fatal(IFormatProvider formatProvider, Action formatMessageCallback) { if (IsFatalEnabled) { Write((LogLevel)32, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), null); } } public virtual void Fatal(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) { if (IsFatalEnabled) { Write((LogLevel)32, new FormatMessageCallbackFormattedMessage(formatProvider, formatMessageCallback), exception); } } } } namespace Common.Logging.Configuration { public static class ArgUtils { public delegate T ParseHandler(string strValue); public delegate void Action(); public delegate T Function(); private static readonly Dictionary s_parsers; static ArgUtils() { s_parsers = new Dictionary(); RegisterTypeParser(Convert.ToBoolean); RegisterTypeParser(Convert.ToInt16); RegisterTypeParser(Convert.ToInt32); RegisterTypeParser(Convert.ToInt64); RegisterTypeParser(Convert.ToSingle); RegisterTypeParser(Convert.ToDouble); RegisterTypeParser(Convert.ToDecimal); } public static void RegisterTypeParser(ParseHandler parser) { s_parsers[typeof(T)] = parser; } public static string GetValue(NameValueCollection values, string key) { return GetValue(values, key, null); } public static string GetValue(NameValueCollection values, string key, string defaultValue) { if (values != null) { foreach (string key2 in values.Keys) { if (string.Compare(key, key2, StringComparison.OrdinalIgnoreCase) == 0) { return values[key]; } } } return defaultValue; } public static string Coalesce(params string[] values) { return Coalesce((string v) => !string.IsNullOrEmpty(v), values); } public static T Coalesce(Predicate predicate, params T[] values) where T : class { if (values == null || values.Length == 0) { return null; } if (predicate == null) { predicate = (T v) => v != null; } foreach (T val in values) { if (predicate(val)) { return val; } } return null; } public static T TryParseEnum(T defaultValue, string stringValue) where T : struct { Type typeFromHandle = typeof(T); if (!typeFromHandle.GetTypeInfo().IsEnum) { throw new ArgumentException($"Type '{typeof(T).FullName}' is not an enum type"); } try { if (!string.IsNullOrEmpty(stringValue)) { return (T)Enum.Parse(typeFromHandle, stringValue, ignoreCase: true); } } catch { } return defaultValue; } public static T TryParse(T defaultValue, string stringValue) { T result = defaultValue; if (string.IsNullOrEmpty(stringValue)) { return defaultValue; } if (!s_parsers.TryGetValue(typeof(T), out var value) || !(value is ParseHandler)) { throw new ArgumentException($"There is no parser registered for type {typeof(T).FullName}"); } ParseHandler parseHandler = (ParseHandler)value; try { result = parseHandler(stringValue); } catch { } return result; } public static T AssertNotNull(string paramName, T val) where T : class { if (val == null) { throw new ArgumentNullException(paramName); } return val; } public static T AssertNotNull(string paramName, T val, string messageFormat, params object[] args) where T : class { if (val == null) { throw new ArgumentNullException(paramName, string.Format(messageFormat, args)); } return val; } public static Type AssertIsAssignable(string paramName, Type valType) { return AssertIsAssignable(paramName, valType, string.Format("Type '{0}' of parameter '{1}' is not assignable to target type '{2}'", ((object)valType == null) ? "" : valType.AssemblyQualifiedName, paramName, typeof(T).AssemblyQualifiedName), Array.Empty()); } public static Type AssertIsAssignable(string paramName, Type valType, string messageFormat, params object[] args) { if ((object)valType == null) { throw new ArgumentNullException("valType"); } if (!TypeExtensions.IsAssignableFrom(typeof(T), valType)) { throw new ArgumentOutOfRangeException(paramName, string.Format(messageFormat, args)); } return valType; } public static void Guard(Action action, string messageFormat, params object[] args) { Guard(delegate { action(); return 0; }, messageFormat, args); } public static T Guard(Function function, string messageFormat, params object[] args) { try { return function(); } catch (ConfigurationException) { throw; } catch (TargetInvocationException ex2) { throw new ConfigurationException(string.Format(messageFormat, args), ex2.InnerException); } catch (Exception rootCause) { throw new ConfigurationException(string.Format(messageFormat, args), rootCause); } } } public class DefaultConfigurationReader : IConfigurationReader { public object GetSection(string sectionName) { return null; } } public class FactoryAdapterConfiguration { public string Type { get; set; } public NameValueCollection Arguments { get; set; } } public class LogConfiguration { public FactoryAdapterConfiguration FactoryAdapter { get; set; } } public class LogConfigurationReader : IConfigurationReader { private readonly LogConfiguration _configuration; public LogConfigurationReader(LogConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } _configuration = configuration; } public object GetSection(string sectionName) { if (_configuration.FactoryAdapter == null) { throw new ConfigurationException("LogConfiguration.FactoryAdapter is required."); } if (string.IsNullOrEmpty(_configuration.FactoryAdapter.Type)) { throw new ConfigurationException("LogConfiguration.FactoryAdapter.Type is required."); } Type type; try { type = Type.GetType(_configuration.FactoryAdapter.Type, throwOnError: true); } catch (Exception rootCause) { throw new ConfigurationException("Unable to create type '" + _configuration.FactoryAdapter.Type + "'", rootCause); } return new LogSetting(type, _configuration.FactoryAdapter.Arguments); } } public class LogSetting { private readonly Type _factoryAdapterType = null; private readonly NameValueCollection _properties = null; public Type FactoryAdapterType => _factoryAdapterType; public NameValueCollection Properties => _properties; public LogSetting(Type factoryAdapterType, NameValueCollection properties) { ArgUtils.AssertNotNull("factoryAdapterType", factoryAdapterType); ArgUtils.AssertIsAssignable("factoryAdapterType", factoryAdapterType, "Type {0} does not implement {1}", new object[2] { factoryAdapterType.AssemblyQualifiedName, typeof(ILoggerFactoryAdapter).FullName }); _factoryAdapterType = factoryAdapterType; _properties = properties; } } public class NameValueCollection : Dictionary { public new string this[string key] { get { if (TryGetValue(key, out var value)) { return value; } return null; } set { base[key] = value; } } public NameValueCollection() : base((IEqualityComparer?)StringComparer.OrdinalIgnoreCase) { } public string[] GetValues(string key) { if (TryGetValue(key, out var value) && value != null) { return new string[1] { value }; } return null; } } }