private static void RegisterEntityFrameworkCoreInterceptor(ILogServiceCollection services, IOptions <EfCoreEnricherOptions> settings) { services.AddDependency(s => s.TryAddSingleton <IServiceProvider>(__efcoreInterceptorFactory, typeof(EfCoreInterceptorDescriptor))); // ReSharper disable once InconsistentNaming object __efcoreInterceptorFactory(IServiceProvider provider) { var instance = new EfCoreInterceptorDescriptor(provider.GetService <ILoggingServiceProvider>(), settings); EfCoreInterceptorDescriptor.Instance = instance; return(instance); } }
private static DatabaseIntegration UseEntityFrameworkCoreInternal(DatabaseIntegration integration, IOptions <EfCoreSinkOptions> settings, Action <IConfiguration, EfCoreSinkConfiguration, LoggingConfiguration> config = null) { var serviceImpl = integration.ExposeServiceCollectionWrapper; if (serviceImpl != null) { serviceImpl.AddExtraSinkSettings <EfCoreSinkOptions, EfCoreSinkConfiguration>(settings.Value, (conf, sink, configuration) => config?.Invoke(conf, sink, configuration)); serviceImpl.AddDependency(s => s.TryAdd(ServiceDescriptor.Singleton(settings))); serviceImpl.AddDependency(s => s.TryAdd(ServiceDescriptor.Singleton(typeof(EfCoreInterceptorDescriptor), provider => { var instance = new EfCoreInterceptorDescriptor(provider.GetService <ILoggingServiceProvider>(), settings); EfCoreInterceptorDescriptor.Instance = instance; return(instance); }))); RegisterCoreComponentsTypes(); } return(integration); }