using System.Collections.Generic; using Microsoft.Extensions.Configuration; using MongoDB.Driver; using Wabbajack.Lib.NexusApi; using Wabbajack.BuildServer.Models.JobQueue; namespace Wabbajack.BuildServer.Models { public class DBContext { private IConfiguration _configuration; private Settings _settings; public DBContext(IConfiguration configuration) { _configuration = configuration; _settings = new Settings(); _configuration.Bind("MongoDB", _settings); } public IMongoCollection> NexusModInfos => Client.GetCollection>(_settings.Collections["NexusModInfos"]); public IMongoCollection> NexusFileInfos => Client.GetCollection>(_settings.Collections["NexusFileInfos"]); public IMongoCollection ModListStatus => Client.GetCollection(_settings.Collections["ModListStatus"]); public IMongoCollection Jobs => Client.GetCollection(_settings.Collections["JobQueue"]); public IMongoCollection DownloadStates => Client.GetCollection(_settings.Collections["DownloadStates"]); public IMongoCollection Metrics => Client.GetCollection(_settings.Collections["Metrics"]); public IMongoCollection IndexedFiles => Client.GetCollection(_settings.Collections["IndexedFiles"]); public IMongoCollection>> NexusUpdates => Client.GetCollection>>(_settings.Collections["NexusUpdates"]); public IMongoCollection ApiKeys => Client.GetCollection(_settings.Collections["ApiKeys"]); public IMongoCollection UploadedFiles => Client.GetCollection(_settings.Collections["UploadedFiles"]); public IMongoCollection> NexusModFiles => Client.GetCollection>( _settings.Collections["NexusModFiles"]); private IMongoDatabase Client => new MongoClient($"mongodb://{_settings.Host}").GetDatabase(_settings.Database); } public class Settings { public string Host { get; set; } public string Database { get; set; } public Dictionary Collections { get; set; } public string SqlConnection { get; set; } } }