Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the TypeImplementer class.
        /// </summary>
        /// <param name="interfaceType">The type to implement.</param>
        public TypeImplementer(Type interfaceType)
        {
            _interfaceType = interfaceType;
            _contextProvider = ProviderManager.GetProvider<TraceContextProvider>(interfaceType, typeof(TraceContextProviderAttribute), null);
            _serializationProvider = TraceSerializationProvider.GetSerializationProvider(interfaceType);
            _eventAttributeProvider = ProviderManager.GetProvider<EventAttributeProvider>(interfaceType, typeof(EventAttributeProviderAttribute), () => new EventAttributeProvider());

            // only interfaces support context
            if (_contextProvider != null && !_interfaceType.IsInterface)
                throw new InvalidOperationException("Context Providers can only be added to interface-based logs.");

            ImplementType();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Registers a EventAttributeProvider for a given event source.
 /// </summary>
 /// <param name="type">The type of event source to register with.</param>
 /// <param name="provider">The provider to register.</param>
 public static void RegisterProvider(Type type, EventAttributeProvider provider)
 {
     RegisterProvider(type, typeof(EventAttributeProvider), provider);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Registers a default EventAttributeProvider for all event sources.
 /// </summary>
 /// <param name="provider">The provider to register.</param>
 public static void RegisterDefaultProvider(EventAttributeProvider provider)
 {
     RegisterProvider(null, provider);
 }
Ejemplo n.º 4
0
 public static void RegisterProvider <TLog>(EventAttributeProvider provider)
 {
     RegisterProvider(typeof(TLog), typeof(EventAttributeProvider), provider);
 }