Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqLiteContext"/> class.
 /// </summary>
 /// <param name="settings">The database settings</param>
 public SqLiteContext(IDbSettings settings)
     : base(new SQLiteConnection() { ConnectionString = ConnectionStringBuilder.BuildConnectionString(ProviderType.SQLite, settings) }, true)
 {
     this.dbSettings = settings;
     this.dbManager.ApplicationContexts.Add(this);
     this.Initialize();
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MySqlContext"/> class.
 /// </summary>
 /// <param name="settings">the database settings</param>
 public MySqlContext(IDbSettings settings)
     : base(new MySqlConnection(ConnectionStringBuilder.BuildConnectionString(ProviderType.MySQL, settings)), true)
 {
     this.dbSettings = settings;
     this.dbManager.ApplicationContexts.Add(this);
     this.Initialize();
 }
        private static IServiceCollection ConfigureServices()
        {
            IServiceCollection services = new ServiceCollection();


            // Set up the objects we need to get to configuration settings
            var config            = LoadConfiguration();
            var dbSettings        = config.GetSection("DbSettings").Get <DbSettings>();
            var threadingSettings = config.GetSection("ThreadingSettings").Get <ThreadingSettings>();

            // Add the config to our DI container for later use
            services.AddSingleton(config);
            services.AddSingleton(dbSettings);
            services.AddSingleton(threadingSettings);

            // EF Db config
            services.AddDbContext <HeroesProfileContext>(options => options.UseMySql(ConnectionStringBuilder.BuildConnectionString(dbSettings)));
            dbSettings.database = "heroesprofile_brawl";
            services.AddDbContext <HeroesProfileBrawlContext>(options => options.UseMySql(ConnectionStringBuilder.BuildConnectionString(dbSettings)));
            dbSettings.database = "heroesprofile_cache";
            services.AddDbContext <HeroesProfileCacheContext>(options => options.UseMySql(ConnectionStringBuilder.BuildConnectionString(dbSettings)));
            dbSettings.database = "heroesprofile";

            services.AddScoped <RunMmrService>();
            services.AddScoped <MmrCalculatorService>();

            // IMPORTANT! Register our application entry point
            services.AddTransient <ConsoleApp>();
            return(services);
        }
Beispiel #4
0
 /// <summary>
 /// Build the Mysql database connection string
 /// </summary>
 /// <returns></returns>
 public string ToConnectionString()
 {
     return(ConnectionStringBuilder.BuildConnectionString(ProviderType.MySQL, mysql));
 }
Beispiel #5
0
 /// <summary>
 /// Build the database connection string
 /// </summary>
 /// <returns></returns>
 public string ToConnectionString()
 {
     return(ConnectionStringBuilder.BuildConnectionString(ProviderType.SQLite, this));
 }