コード例 #1
0
 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;
 }
コード例 #2
0
 /// <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;
     }
 }
コード例 #3
0
 public TestCommonLoggingEntlibTraceListener(CommonLoggingEntlibTraceListenerData data, ILogFormatter logFormatter)
     : base(data, logFormatter)
 {
     if (Instance != null)
     {
         throw new NotSupportedException(this.GetType().FullName + " supports only one instance");
     }
     Instance = this;
 }
コード例 #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;
 }
コード例 #6
0
 /// <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;
 }