Ejemplo n.º 1
0
        public void UpdateConfiguration(MySqlServiceInfo si, MySqlProviderConnectorOptions configuration)
        {
            if (si == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(si.Uri))
            {
                configuration.Port = si.Port;
                if (configuration.UrlEncodedCredentials)
                {
                    configuration.Username = WebUtility.UrlDecode(si.UserName);
                    configuration.Password = WebUtility.UrlDecode(si.Password);
                }
                else
                {
                    configuration.Username = si.UserName;
                    configuration.Password = si.Password;
                }

                configuration.Server   = si.Host;
                configuration.Database = si.Path;
            }
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        private Connection GetConnection(MySqlServiceInfo info, IConfiguration configuration)
        {
            var mySqlConfig = new MySqlProviderConnectorOptions(configuration);
            var configurer  = new MySqlProviderConfigurer();

            return(new Connection(configurer.Configure(info, mySqlConfig), "MySql", info));
        }
Ejemplo n.º 4
0
        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 RelationalDbHealthContributor((IDbConnection)factory.Create(ctx), ctx.GetService <ILogger <RelationalDbHealthContributor> >()), ServiceLifetime.Singleton));
            }
        }
        public void UpdateConfiguration(MySqlServiceInfo si, MySqlProviderConnectorOptions configuration)
        {
            if (si == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(si.Uri))
            {
                configuration.Port     = si.Port;
                configuration.Username = si.UserName;
                configuration.Password = si.Password;
                configuration.Server   = si.Host;
                configuration.Database = si.Path;
            }
        }
Ejemplo n.º 6
0
 public MySqlProviderConnectorFactory(MySqlServiceInfo sinfo, MySqlProviderConnectorOptions config, Type type)
 {
     _info         = sinfo;
     _config       = config ?? throw new ArgumentNullException(nameof(config));
     ConnectorType = type;
 }
 public string Configure(MySqlServiceInfo si, MySqlProviderConnectorOptions configuration)
 {
     UpdateConfiguration(si, configuration);
     return(configuration.ToString());
 }