Reworking the plugin interface and moving the database to an external dll

This commit is contained in:
Zoe Roux
2021-04-28 23:40:22 +02:00
parent b7294114b9
commit 833447ded8
21 changed files with 365 additions and 2360 deletions
+49
View File
@@ -0,0 +1,49 @@
using System;
using Kyoo.Controllers;
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Unity;
using Unity.Injection;
using Unity.Lifetime;
using Unity.Resolution;
namespace Kyoo.Postgresql
{
/// <summary>
/// A module to add postgresql capacity to the app.
/// </summary>
public class PostgresModule : IPlugin
{
/// <inheritdoc />
public string Slug => "postgresql";
/// <inheritdoc />
public string Name => "Postgresql";
/// <inheritdoc />
public string Description => "A database context for postgresql.";
/// <inheritdoc />
public string[] Provides => new[]
{
$"{nameof(DatabaseContext)}:{nameof(PostgresContext)}"
};
/// <inheritdoc />
public string[] Requires => Array.Empty<string>();
/// <inheritdoc />
public void Configure(IUnityContainer container, IConfiguration config, IApplicationBuilder app, bool debugMode)
{
// options.UseNpgsql(_configuration.GetDatabaseConnection());
// // // .EnableSensitiveDataLogging()
// // // .UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()));
container.RegisterFactory<DatabaseContext>(_ =>
{
return new PostgresContext(config.GetDatabaseConnection(), debugMode);
});
}
}
}