private static void DoAdd(IServiceCollection services, MySqlServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime) { Type mySqlConnection = ConnectorHelpers.FindType(mySqlAssemblies, mySqlTypeNames); if (mySqlConnection == null) { throw new ConnectorException("Unable to find MySqlConnection, are you missing MySql ADO.NET assembly"); } MySqlProviderConnectorOptions mySqlConfig = new MySqlProviderConnectorOptions(config); MySqlProviderConnectorFactory factory = new MySqlProviderConnectorFactory(info, mySqlConfig, mySqlConnection); services.Add(new ServiceDescriptor(typeof(IDbConnection), factory.Create, contextLifetime)); services.Add(new ServiceDescriptor(mySqlConnection, factory.Create, contextLifetime)); }
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()); } }