forked from PGR/ascnet
1
0
Fork 0
ascnet/AscNet.Common/Common.cs

26 lines
823 B
C#
Raw Normal View History

2023-10-06 13:29:27 +00:00
using MongoDB.Driver;
using Config.Net;
namespace AscNet.Common
{
public static class Common
{
public static readonly IConfig config;
public static readonly MongoClient mongoClient;
public static readonly IMongoDatabase db;
static Common()
{
config = new ConfigurationBuilder<IConfig>().UseJsonFile("Configs/config.json").Build();
mongoClient = new(
new MongoClientSettings
{
Server = new MongoServerAddress(config.Database.Host, config.Database.Port),
// Credential = MongoCredential.CreateCredential("admin", config.Database.Username, config.Database.Password)
}
);
db = mongoClient.GetDatabase(config.Database.Name);
}
}
}