internal static void AllDone(ILogServiceCollection services)
        {
            if (services is ConsoleLogServiceCollection loggingServices)
            {
                using (loggingServices) {
                    loggingServices.ActiveConsolePreferencesRenderers();

                    loggingServices.RegisterCoreComponents();

                    loggingServices.BuildAndActiveConfiguration();

                    loggingServices.AddTraceIdGenerator();
                }

                ServiceResolver = loggingServices.OriginalServices.ToServiceContext().Build();

                loggingServices.ActiveLogEventEnrichers();

                StaticServiceResolver.SetResolver(ServiceResolver.ResolveRequired <ILoggingServiceProvider>());
            }
            else
            {
                throw new ArgumentException(nameof(services));
            }
        }
        private static IServiceCollection RegisterToAspNetCore(IServiceCollection services, IConfigurationRoot root, Action <ILogServiceCollection> config = null)
        {
            var servicesImpl = new AspNetCoreLogServiceCollection(services, root);

            config?.Invoke(servicesImpl);

            services.TryAdd(ServiceDescriptor.Scoped <IHttpContextAccessor, HttpContextAccessor>());
            services.TryAdd(ServiceDescriptor.Singleton <ILoggingServiceProvider, AspNetCoreLoggingServiceProvider>());
            services.TryAdd(ServiceDescriptor.Singleton(typeof(ILogger <>), typeof(AspNetCoreLoggerWrapper <>)));

            servicesImpl.BuildConfiguration();
            servicesImpl.ActiveSinkSettings();
            servicesImpl.ActiveOriginConfiguration();

            services.TryAdd(ServiceDescriptor.Singleton(Options.Options.Create((LoggingOptions)servicesImpl.ExposeLogSettings())));
            services.TryAdd(ServiceDescriptor.Singleton(servicesImpl.ExposeLoggingConfiguration()));
            services.TryAdd(ServiceDescriptor.Singleton <ILoggerFactory>(provider => new AspNetCoreLoggerFactory(provider.GetService <ILoggingServiceProvider>())));

            if (StaticServiceResolveInitialization.UsingSecInitializingActivation)
            {
                services.TryAdd(ServiceDescriptor.Singleton <ISecInitializingActivation>(provider => {
                    var initializingActivationImpl = new AspNetCoreSecInitializingActivation();
                    initializingActivationImpl.AppendAction(() => StaticServiceResolver.SetResolver(provider.GetRequiredService <ILoggingServiceProvider>()));
                    return(initializingActivationImpl);
                }));
            }
            else
            {
                services.TryAdd(ServiceDescriptor.Singleton(provider => new StaticServiceResolveInitialization(provider.GetRequiredService <ILoggingServiceProvider>())));
            }


            return(services);
        }
 public StaticServiceResolveInitialization(ILoggingServiceProvider loggingServiceProvider)
 {
     if (loggingServiceProvider == null)
     {
         throw new ArgumentNullException(nameof(loggingServiceProvider));
     }
     StaticServiceResolver.SetResolver(loggingServiceProvider);
 }
Esempio n. 4
0
 private static void RegisterPostBuiltAction(this AutofacServiceCollection services)
 {
     services.AddPostRegisterAction("AfterBuild", builder =>
                                    builder.RegisterBuildCallback(container => {
         services.ActiveLogEventEnrichers();
         StaticServiceResolver.SetResolver(container.Resolve <ILoggingServiceProvider>());
     }));
 }
 private static void RegisterCallback(this StandardLogServiceCollection services)
 {
     services.AddDependency(s => s.AddSingleton <StandardSecInitializingCallback, IServiceProvider>(provider => {
         var callback = new StandardSecInitializingCallback();
         callback.AppendAction(services.ActiveLogEventEnrichers);
         callback.AppendAction(() => StaticServiceResolver.SetResolver(provider.GetService <ILoggingServiceProvider>()));
         return(callback);
     }));
 }
 public StaticServiceResolveInitialization(ILoggingServiceProvider loggingServiceProvider, Action additionalAction = null)
 {
     if (loggingServiceProvider is null)
     {
         throw new ArgumentNullException(nameof(loggingServiceProvider));
     }
     StaticServiceResolver.SetResolver(loggingServiceProvider);
     additionalAction?.Invoke();
 }
 internal static void AllDone(ILogServiceCollection services)
 {
     if (services is ConsoleLogServiceCollection servicesImpl)
     {
         servicesImpl.BuildConfiguration();
         servicesImpl.ActiveSinkSettings();
         servicesImpl.ActiveOriginConfiguration();
         servicesImpl.AddDependency(s => s.TryAdd(ServiceDescriptor.Singleton(Options.Create((LoggingOptions)servicesImpl.ExposeLogSettings()))));
         servicesImpl.AddDependency(s => s.TryAdd(ServiceDescriptor.Singleton(servicesImpl.ExposeLoggingConfiguration())));
         ServiceResolver = servicesImpl.ExposeServices().ToServiceContainer().Build();
         StaticServiceResolver.SetResolver(ServiceResolver.ResolveRequired <ILoggingServiceProvider>());
     }
     else
     {
         throw new ArgumentException(nameof(services));
     }
 }
        public static IContainer RegisterCosmosLogging(this IContainer ioc, Action <ILogServiceCollection> config)
        {
            var serviceImpl = new ZkWebLogServiceCollection();

            config?.Invoke(serviceImpl);

            ioc.Register <ILoggingServiceProvider, ZKWebLoggingServiceProvider>(ReuseType.Singleton);

            serviceImpl.BuildConfiguration();
            serviceImpl.ActiveSinkSettings();
            serviceImpl.ActiveOriginConfiguration();

            ioc.RegisterFromServiceCollection(serviceImpl.ExposeServices());
            ioc.RegisterInstance(Options.Create((LoggingOptions)serviceImpl.ExposeLogSettings()), ReuseType.Singleton);
            ioc.RegisterInstance(serviceImpl.ExposeLoggingConfiguration(), ReuseType.Singleton);

            StaticServiceResolver.SetResolver(ioc.Resolve <ILoggingServiceProvider>());

            return(ioc);
        }
        /// <summary>
        /// Register Cosmos Logging to ZKWeb IOC
        /// </summary>
        /// <param name="ioc"></param>
        /// <param name="serviceConfigure"></param>
        /// <returns></returns>
        public static IContainer RegisterCosmosLogging(this IContainer ioc, Action <ILogServiceCollection> serviceConfigure)
        {
            var loggingServices = new ZkWebLogServiceCollection();

            loggingServices.RegisterCoreComponents(serviceConfigure);

            ioc.Register <ILoggingServiceProvider, ZKWebLoggingServiceProvider>(ReuseType.Singleton);
            ioc.Register <IPropertyFactoryAccessor, ShortcutPropertyFactoryAccessor>();

            ioc.RegisterFromServiceCollection(loggingServices.OriginalServices);
            ioc.RegisterTraceIdGenerator();
            ioc.RegisterInstance(Options.Create((LoggingOptions)loggingServices.ExposeLogSettings()), ReuseType.Singleton);
            ioc.RegisterInstance(loggingServices.ExposeLoggingConfiguration(), ReuseType.Singleton);

            StaticServiceResolver.SetResolver(ioc.Resolve <ILoggingServiceProvider>());

            loggingServices.ActiveLogEventEnrichers();

            return(ioc);
        }
Esempio n. 10
0
 private static void UpdateStaticProvider()
 {
     StaticServiceResolver.SetResolver(NancyContainerSolo.ServiceProvider.GetRequiredService <ILoggingServiceProvider>());
 }
Esempio n. 11
0
 private static void UpdateStaticProvider(ILifetimeScope container)
 {
     StaticServiceResolver.SetResolver(container.Resolve <ILoggingServiceProvider>());
 }