2023-09-01 22:33:36 +00:00
|
|
|
using BotSharp.Plugin.MongoStorage.Repository;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.Plugin.MongoStorage;
|
|
|
|
|
|
|
|
|
|
public class MongoStoragePlugin : IBotSharpPlugin
|
|
|
|
|
{
|
|
|
|
|
public void RegisterDI(IServiceCollection services, IConfiguration config)
|
|
|
|
|
{
|
2023-09-09 20:30:39 +00:00
|
|
|
var dbSettings = new BotSharpDatabaseSettings();
|
|
|
|
|
config.Bind("Database", dbSettings);
|
|
|
|
|
|
2023-09-03 19:32:12 +00:00
|
|
|
if (dbSettings.Default == "MongoRepository")
|
2023-09-02 05:10:46 +00:00
|
|
|
{
|
2023-09-03 19:32:12 +00:00
|
|
|
services.AddScoped((IServiceProvider x) =>
|
|
|
|
|
{
|
|
|
|
|
var dbSettings = x.GetRequiredService<BotSharpDatabaseSettings>();
|
|
|
|
|
return new MongoDbContext(dbSettings.MongoDb);
|
|
|
|
|
});
|
2023-09-01 22:33:36 +00:00
|
|
|
|
2023-09-03 19:32:12 +00:00
|
|
|
services.AddScoped<IBotSharpRepository, MongoRepository>();
|
|
|
|
|
}
|
2023-09-01 22:33:36 +00:00
|
|
|
}
|
|
|
|
|
}
|