public static IServiceCollection AddLamar(this IServiceCollection services, ServiceRegistry registry, LoggingAndOptionResolving resolving) { services.AddSingleton <IServiceProviderFactory <ServiceRegistry>, LamarServiceProviderFactory>(); services.AddSingleton <IServiceProviderFactory <IServiceCollection>, LamarServiceProviderFactory>(); if (resolving == LoggingAndOptionResolving.Lamar) { services.AddSingleton <IRegistrationPolicy>(new LoggerPolicy()); services.AddSingleton <IFamilyPolicy>(new LoggerPolicy()); services.AddSingleton <IRegistrationPolicy>(new OptionsPolicy()); services.AddSingleton <IFamilyPolicy>(new OptionsPolicy()); } if (registry != null) { foreach (var descriptor in registry) { services.Add(descriptor); } } return(services); }
public static IServiceCollection AddLamar(this IServiceCollection services, ServiceRegistry registry, LoggingAndOptionResolving resolving) { services.AddSingleton <IServiceProviderFactory <ServiceRegistry>, LamarServiceProviderFactory>(); services.AddSingleton <IServiceProviderFactory <IServiceCollection>, LamarServiceProviderFactory>(); registry = registry ?? new ServiceRegistry(); registry.For <LoggerFilterOptions>().Use(c => c.GetInstance <IOptions <LoggerFilterOptions> >().Value); if (resolving == LoggingAndOptionResolving.Lamar) { registry.Policies.Add(new LoggerPolicy()); registry.Policies.Add(new OptionsPolicy()); } foreach (var descriptor in registry) { services.Add(descriptor); } return(services); }
public static IHostBuilder UseLamar(this IHostBuilder builder, ServiceRegistry registry, LoggingAndOptionResolving resolving) { return(builder .UseServiceProviderFactory <ServiceRegistry>(new LamarServiceProviderFactory()) .ConfigureServices((context, services) => { services.AddLamar(registry, resolving); })); }
public static IHostBuilder UseLamar(this IHostBuilder builder, LoggingAndOptionResolving resolving) { return(UseLamar(builder, registry: null, resolving: resolving)); }
public static IServiceCollection AddLamar(this IServiceCollection services, LoggingAndOptionResolving resolving) { return(AddLamar(services, registry: null, resolving: resolving)); }
public static IServiceCollection AddLamar <T>(this IServiceCollection services, LoggingAndOptionResolving resolving = LoggingAndOptionResolving.Lamar) where T : ServiceRegistry, new() { return(services.AddLamar(new T(), resolving)); }
public static IWebHostBuilder UseLamar(this IWebHostBuilder builder, ServiceRegistry registry, LoggingAndOptionResolving resolving) { return(builder.ConfigureServices(services => { services.AddLamar(registry, resolving); })); }