2021-12-31 08:59:02 +01:00
|
|
|
using System;
|
2020-11-17 13:46:23 +01:00
|
|
|
using BTCPayServer.Abstractions.Contracts;
|
|
|
|
using BTCPayServer.Abstractions.Models;
|
|
|
|
using BTCPayServer.Abstractions.Services;
|
|
|
|
using BTCPayServer.Plugins.Test.Services;
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2020-10-21 14:02:20 +02:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Plugins.Test
|
|
|
|
{
|
2021-12-31 08:59:02 +01:00
|
|
|
public class TestPlugin : BaseBTCPayServerPlugin
|
2020-10-21 14:02:20 +02:00
|
|
|
{
|
2021-12-31 08:59:02 +01:00
|
|
|
public override string Identifier { get; } = "BTCPayServer.Plugins.Test";
|
|
|
|
public override string Name { get; } = "Test Plugin!";
|
|
|
|
public override string Description { get; } = "This is a description of the loaded test extension!";
|
2020-10-21 14:02:20 +02:00
|
|
|
|
|
|
|
public override void Execute(IServiceCollection services)
|
|
|
|
{
|
|
|
|
services.AddSingleton<IUIExtension>(new UIExtension("TestExtensionNavExtension", "header-nav"));
|
|
|
|
services.AddHostedService<ApplicationPartsLogger>();
|
2020-11-17 13:46:23 +01:00
|
|
|
services.AddSingleton<TestPluginService>();
|
|
|
|
services.AddSingleton<TestPluginDbContextFactory>();
|
|
|
|
services.AddDbContext<TestPluginDbContext>((provider, o) =>
|
|
|
|
{
|
|
|
|
var factory = provider.GetRequiredService<TestPluginDbContextFactory>();
|
|
|
|
factory.ConfigureBuilder(o);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Execute(IApplicationBuilder applicationBuilder, IServiceProvider applicationBuilderApplicationServices)
|
|
|
|
{
|
|
|
|
base.Execute(applicationBuilder, applicationBuilderApplicationServices);
|
|
|
|
applicationBuilderApplicationServices.GetService<TestPluginDbContextFactory>().CreateContext().Database.Migrate();
|
|
|
|
applicationBuilderApplicationServices.GetService<TestPluginService>().AddTestDataRecord().GetAwaiter().GetResult();
|
2021-12-31 08:59:02 +01:00
|
|
|
|
2020-10-21 14:02:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|