示例#1
0
        private static void DoAdd(IServiceCollection services, OracleServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime)
        {
            var oracleConfig = new OracleProviderConnectorOptions(config);
            var factory      = new OracleProviderConnectorFactory(info, oracleConfig, OracleTypeLocator.OracleConnection);

            services.Add(new ServiceDescriptor(typeof(IHealthContributor), ctx => new RelationalHealthContributor((IDbConnection)factory.Create(ctx), ctx.GetService <ILogger <RelationalHealthContributor> >()), contextLifetime));
        }
        private static void DoAdd(IServiceCollection services, OracleServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime, bool addSteeltoeHealthChecks)
        {
            var oracleConnection = ReflectionHelpers.FindType(OracleTypeLocator.Assemblies, OracleTypeLocator.ConnectionTypeNames);
            var oracleConfig     = new OracleProviderConnectorOptions(config);
            var factory          = new OracleProviderConnectorFactory(info, oracleConfig, oracleConnection);

            services.Add(new ServiceDescriptor(typeof(IDbConnection), factory.Create, contextLifetime));
            services.Add(new ServiceDescriptor(oracleConnection, 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, OracleServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime, IHealthChecksBuilder builder)
        {
            Type OracleConnection = ConnectorHelpers.FindType(OracleTypeLocator.Assemblies, OracleTypeLocator.ConnectionTypeNames);
            var  OracleConfig     = new OracleProviderConnectorOptions(config);
            var  factory          = new OracleProviderConnectorFactory(info, OracleConfig, OracleConnection);

            services.Add(new ServiceDescriptor(typeof(IDbConnection), factory.Create, contextLifetime));
            services.Add(new ServiceDescriptor(OracleConnection, factory.Create, contextLifetime));
            if (builder == null)
            {
                services.Add(new ServiceDescriptor(typeof(IHealthContributor), ctx => new SkynetCloudRelationalHealthContributor((IDbConnection)factory.Create(ctx), ctx.GetService <ILogger <SkynetCloudRelationalHealthContributor> >()), ServiceLifetime.Singleton));
            }
            else
            {
                builder.AddOracle(factory.CreateConnectionString());
            }
        }