コード例 #1
0
        private static void DoAdd(IServiceCollection services, PostgresServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime)
        {
            PostgresProviderConnectorOptions PostgresConfig = new PostgresProviderConnectorOptions(config);
            PostgresProviderConnectorFactory factory        = new PostgresProviderConnectorFactory(info, PostgresConfig);

            services.Add(new ServiceDescriptor(typeof(NpgsqlConnection), factory.Create, contextLifetime));
        }
コード例 #2
0
        private static void DoAdd(IServiceCollection services, PostgresServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime)
        {
            var postgresConfig = new PostgresProviderConnectorOptions(config);
            var factory        = new PostgresProviderConnectorFactory(info, postgresConfig, PostgreSqlTypeLocator.NpgsqlConnection);

            services.Add(new ServiceDescriptor(typeof(IHealthContributor), ctx => new RelationalHealthContributor((IDbConnection)factory.Create(ctx), ctx.GetService <ILogger <RelationalHealthContributor> >()), contextLifetime));
        }
コード例 #3
0
        private static void DoAdd(IServiceCollection services, PostgresServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime)
        {
            Type postgresConnection = ConnectorHelpers.FindType(PostgreSqlTypeLocator.Assemblies, PostgreSqlTypeLocator.ConnectionTypeNames);
            var  postgresConfig     = new PostgresProviderConnectorOptions(config);
            var  factory            = new PostgresProviderConnectorFactory(info, postgresConfig, postgresConnection);

            services.Add(new ServiceDescriptor(typeof(IDbConnection), factory.Create, contextLifetime));
            services.Add(new ServiceDescriptor(postgresConnection, factory.Create, contextLifetime));
            services.Add(new ServiceDescriptor(typeof(IHealthContributor), ctx => new RelationalHealthContributor((IDbConnection)factory.Create(ctx), ctx.GetService <ILogger <RelationalHealthContributor> >()), ServiceLifetime.Singleton));
        }
コード例 #4
0
        private static void DoAdd(IServiceCollection services, PostgresServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime)
        {
            Type postgresConnection = ConnectorHelpers.FindType(postgresAssemblies, postgresTypeNames);

            if (postgresConnection == null)
            {
                throw new ConnectorException("Unable to find NpgsqlConnection, are you missing Postgres ADO.NET assembly");
            }

            PostgresProviderConnectorOptions postgresConfig = new PostgresProviderConnectorOptions(config);
            PostgresProviderConnectorFactory factory        = new PostgresProviderConnectorFactory(info, postgresConfig, postgresConnection);

            services.Add(new ServiceDescriptor(typeof(IDbConnection), factory.Create, contextLifetime));
            services.Add(new ServiceDescriptor(postgresConnection, factory.Create, contextLifetime));
        }