Esempio n. 1
0
        internal void UpdateConfiguration(MySqlServiceInfo si, MySqlProviderConfiguration 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;
            }
        }
        public static IServiceCollection AddMySqlConnection(this IServiceCollection services, IConfiguration config, ILoggerFactory logFactory = null)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }


            MySqlProviderConfiguration    mySqlConfig = new MySqlProviderConfiguration(config);
            MySqlServiceInfo              info        = config.GetSingletonServiceInfo <MySqlServiceInfo>();
            MySqlProviderConnectorFactory factory     = new MySqlProviderConnectorFactory(info, mySqlConfig);

            services.AddScoped(typeof(MySqlConnection), factory.Create);
            return(services);
        }
 public MySqlProviderConnectorFactory(MySqlServiceInfo sinfo, MySqlProviderConfiguration config)
 {
     _info   = sinfo;
     _config = config;
 }
Esempio n. 4
0
 internal string Configure(MySqlServiceInfo si, MySqlProviderConfiguration configuration)
 {
     UpdateConfiguration(si, configuration);
     return(configuration.ToString());
 }