private static void DoAdd(IServiceCollection services, SqlServerServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime)
        {
            var sqlServerConfig = new SqlServerProviderConnectorOptions(config);
            var factory         = new SqlServerProviderConnectorFactory(info, sqlServerConfig, SqlServerTypeLocator.SqlConnection);

            services.Add(new ServiceDescriptor(typeof(IHealthContributor), ctx => new RelationalHealthContributor((IDbConnection)factory.Create(ctx), ctx.GetService <ILogger <RelationalHealthContributor> >()), contextLifetime));
        }
Ejemplo n.º 2
0
        private static void DoAdd(IServiceCollection services, SqlServerServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime, bool addSteeltoeHealthChecks)
        {
            var sqlServerConnection = SqlServerTypeLocator.SqlConnection;
            var sqlServerConfig     = new SqlServerProviderConnectorOptions(config);
            var factory             = new SqlServerProviderConnectorFactory(info, sqlServerConfig, sqlServerConnection);

            services.Add(new ServiceDescriptor(typeof(IDbConnection), factory.Create, contextLifetime));
            services.Add(new ServiceDescriptor(sqlServerConnection, factory.Create, contextLifetime));
            if (!services.Any(s => s.ServiceType == typeof(HealthCheckService)) || addSteeltoeHealthChecks)
            {
                services.Add(new ServiceDescriptor(typeof(IHealthContributor), ctx => new RelationalDbHealthContributor((IDbConnection)factory.Create(ctx), ctx.GetService <ILogger <RelationalDbHealthContributor> >()), ServiceLifetime.Singleton));
            }
        }