private static void DoAdd(IServiceCollection services, MySqlServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime, bool addSteeltoeHealthChecks) { var mySqlConnection = ReflectionHelpers.FindType(MySqlTypeLocator.Assemblies, MySqlTypeLocator.ConnectionTypeNames); var mySqlConfig = new MySqlProviderConnectorOptions(config); var factory = new MySqlProviderConnectorFactory(info, mySqlConfig, mySqlConnection); services.Add(new ServiceDescriptor(typeof(IDbConnection), factory.Create, contextLifetime)); services.Add(new ServiceDescriptor(mySqlConnection, factory.Create, contextLifetime)); if (!services.Any(s => s.ServiceType == typeof(HealthCheckService)) || addSteeltoeHealthChecks) { services.Add(new ServiceDescriptor(typeof(IHealthContributor), ctx => new RelationalHealthContributor((IDbConnection)factory.Create(ctx), ctx.GetService <ILogger <RelationalHealthContributor> >()), ServiceLifetime.Singleton)); } }
private static void DoAdd(IServiceCollection services, MySqlServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime, IHealthChecksBuilder builder) { Type mySqlConnection = ConnectorHelpers.FindType(MySqlTypeLocator.Assemblies, MySqlTypeLocator.ConnectionTypeNames); var mySqlConfig = new MySqlProviderConnectorOptions(config); var factory = new MySqlProviderConnectorFactory(info, mySqlConfig, mySqlConnection); services.Add(new ServiceDescriptor(typeof(IDbConnection), factory.Create, contextLifetime)); services.Add(new ServiceDescriptor(mySqlConnection, factory.Create, contextLifetime)); if (builder == null) { services.Add(new ServiceDescriptor(typeof(IHealthContributor), ctx => new RelationalHealthContributor((IDbConnection)factory.Create(ctx), ctx.GetService <ILogger <RelationalHealthContributor> >()), ServiceLifetime.Singleton)); } else { builder.AddMySql(factory.CreateConnectionString()); } }
private static void DoAdd(IServiceCollection services, MySqlServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime) { var mySqlConfig = new MySqlProviderConnectorOptions(config); var factory = new MySqlProviderConnectorFactory(info, mySqlConfig, MySqlTypeLocator.MySqlConnection); services.Add(new ServiceDescriptor(typeof(IHealthContributor), ctx => new RelationalHealthContributor((IDbConnection)factory.Create(ctx), ctx.GetService <ILogger <RelationalHealthContributor> >()), contextLifetime)); }