private TraceListener CreateListener(IUnityContainer c)
 {
     var formatter = new TextFormatter("{message}{dictionary({key} - {value}{newline})}");
     var data = new CommonLoggingEntlibTraceListenerData(this.GetType().FullName, "{listenerName}.{sourceName}", "Text Formatter");
     var listener = new CommonLoggingEntlibTraceListener(data, formatter);
     return listener;
 }
 /// <summary>
 /// Initializes this instance from <see cref="CommonLoggingEntlibTraceListenerData"/> configuration
 /// information.
 /// </summary>
 public CommonLoggingEntlibTraceListener(CommonLoggingEntlibTraceListenerData data, ILogFormatter formatter)
     : base(formatter)
 {
     if (data.LoggerNameFormat != null)
     {
         _loggerNameFormat = data.LoggerNameFormat;
     }
 }
 public TestCommonLoggingEntlibTraceListener(CommonLoggingEntlibTraceListenerData data, ILogFormatter logFormatter)
     : base(data, logFormatter)
 {
     if (Instance != null)
     {
         throw new NotSupportedException(this.GetType().FullName + " supports only one instance");
     }
     Instance = this;
 }
Exemple #4
0
        ///<summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="CommonLoggingEntlibTraceListener"/> described by a
        /// <see cref="CommonLoggingEntlibTraceListenerData"/> configuration object.
        ///</summary>
        public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            CommonLoggingEntlibTraceListenerData data = (CommonLoggingEntlibTraceListenerData)objectConfiguration;
            ILogFormatter formatter = base.GetFormatter(context, data.Formatter, configurationSource, reflectionCache);

            CommonLoggingEntlibTraceListener listener = (CommonLoggingEntlibTraceListener)System.Activator.CreateInstance(objectConfiguration.Type, new object[] { objectConfiguration, formatter });

            return(listener);
        }
 public TestCommonLoggingEntlibTraceListener(CommonLoggingEntlibTraceListenerData data, ILogFormatter logFormatter)
     : base(data, logFormatter)
 {
     if (Instance != null)
     {
         throw new NotSupportedException(this.GetType().FullName + " supports only one instance");
     }
     Instance = this;
 }
 /// <summary>
 /// Initializes this instance from <see cref="CommonLoggingEntlibTraceListenerData"/> configuration
 /// information.
 /// </summary>
 public CommonLoggingEntlibTraceListener(CommonLoggingEntlibTraceListenerData data, ILogFormatter formatter)
     :base(formatter)
 {
     if (data.LoggerNameFormat != null)
     {
         _loggerNameFormat = data.LoggerNameFormat;
     }
     _loggerName = data.Name;
 }