minor cleanup (#651)
This commit is contained in:
parent
ce6cedaf4b
commit
7a2891573b
|
@ -71,6 +71,7 @@ namespace StardewModdingAPI.Web
|
||||||
options.SerializerSettings.Formatting = Formatting.Indented;
|
options.SerializerSettings.Formatting = Formatting.Indented;
|
||||||
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
|
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
|
||||||
});
|
});
|
||||||
|
MongoDbConfig mongoConfig = this.Configuration.GetSection("MongoDB").Get<MongoDbConfig>();
|
||||||
|
|
||||||
// init background service
|
// init background service
|
||||||
{
|
{
|
||||||
|
@ -80,12 +81,10 @@ namespace StardewModdingAPI.Web
|
||||||
}
|
}
|
||||||
|
|
||||||
// init MongoDB
|
// init MongoDB
|
||||||
MongoDbConfig mongoConfig = this.Configuration.GetSection("MongoDB").Get<MongoDbConfig>();
|
services.AddSingleton<IMongoDatabase>(serv => new MongoClient(mongoConfig.GetConnectionString()).GetDatabase(mongoConfig.Database));
|
||||||
string mongoConnectionStr = mongoConfig.GetConnectionString();
|
services.AddSingleton<IWikiCacheRepository>(serv => new WikiCacheRepository(serv.GetRequiredService<IMongoDatabase>()));
|
||||||
services.AddSingleton<IMongoDatabase>(serv => new MongoClient(mongoConnectionStr).GetDatabase(mongoConfig.Database));
|
|
||||||
services.AddSingleton<IWikiCacheRepository>(serv => new WikiCacheRepository(serv.GetService<IMongoDatabase>()));
|
|
||||||
|
|
||||||
// init Hangfire (needs MongoDB)
|
// init Hangfire
|
||||||
services
|
services
|
||||||
.AddHangfire(config =>
|
.AddHangfire(config =>
|
||||||
{
|
{
|
||||||
|
@ -93,7 +92,7 @@ namespace StardewModdingAPI.Web
|
||||||
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
|
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
|
||||||
.UseSimpleAssemblyNameTypeSerializer()
|
.UseSimpleAssemblyNameTypeSerializer()
|
||||||
.UseRecommendedSerializerSettings()
|
.UseRecommendedSerializerSettings()
|
||||||
.UseMongoStorage(mongoConnectionStr, $"{mongoConfig.Database}-hangfire", new MongoStorageOptions
|
.UseMongoStorage(mongoConfig.GetConnectionString(), $"{mongoConfig.Database}-hangfire", new MongoStorageOptions
|
||||||
{
|
{
|
||||||
MigrationOptions = new MongoMigrationOptions(MongoMigrationStrategy.Drop)
|
MigrationOptions = new MongoMigrationOptions(MongoMigrationStrategy.Drop)
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue