예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public static IHostBuilder UseLamar(this IHostBuilder builder, ServiceRegistry registry, LoggingAndOptionResolving resolving)
 {
     return(builder
            .UseServiceProviderFactory <ServiceRegistry>(new LamarServiceProviderFactory())
            .ConfigureServices((context, services) => { services.AddLamar(registry, resolving); }));
 }
예제 #4
0
 public static IHostBuilder UseLamar(this IHostBuilder builder, LoggingAndOptionResolving resolving)
 {
     return(UseLamar(builder, registry: null, resolving: resolving));
 }
예제 #5
0
 public static IServiceCollection AddLamar(this IServiceCollection services, LoggingAndOptionResolving resolving)
 {
     return(AddLamar(services, registry: null, resolving: resolving));
 }
예제 #6
0
 public static IServiceCollection AddLamar <T>(this IServiceCollection services, LoggingAndOptionResolving resolving = LoggingAndOptionResolving.Lamar) where T : ServiceRegistry, new()
 {
     return(services.AddLamar(new T(), resolving));
 }
예제 #7
0
 public static IWebHostBuilder UseLamar(this IWebHostBuilder builder, ServiceRegistry registry, LoggingAndOptionResolving resolving)
 {
     return(builder.ConfigureServices(services => { services.AddLamar(registry, resolving); }));
 }