public DiagnosticObserver( DiagnosticObserverOptions <TDiagnosticHandler> options, TDiagnosticHandler handler) { _options = options; _handler = handler; }
public static IServiceCollection AddDiagnosticObserver <TDiagnosticHandler>(this IServiceCollection services, Action <DiagnosticObserverOptions <TDiagnosticHandler> > configure) where TDiagnosticHandler : class, IDiagnosticHandler { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (configure == null) { throw new ArgumentNullException(nameof(configure)); } services.TryAddTransient <DiagnosticObserverOptions <TDiagnosticHandler> >(serviceProvider => { var options = new DiagnosticObserverOptions <TDiagnosticHandler>(); configure(options); return(options); }); services.TryAddTransient <TDiagnosticHandler>(); services.TryAddEnumerable( ServiceDescriptor.Transient <IDiagnosticObserver, DiagnosticObserver <TDiagnosticHandler> >()); return(services); }