mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 02:28:31 +01:00
179520a211
This allows plugins to create custom dbcontexts, which would be namespaced in the scheme with a prefix. Migrations are supported too and the table would be prefixed too
27 lines
859 B
C#
27 lines
859 B
C#
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Abstractions.Contracts;
|
|
using BTCPayServer.Hosting;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Microsoft.AspNetCore.Hosting
|
|
{
|
|
public static class WebHostExtensions
|
|
{
|
|
public static async Task StartWithTasksAsync(this IWebHost webHost, CancellationToken cancellationToken = default)
|
|
{
|
|
// Load all tasks from DI
|
|
var startupTasks = webHost.Services.GetServices<IStartupTask>();
|
|
|
|
// Execute all the tasks
|
|
foreach (var startupTask in startupTasks)
|
|
{
|
|
await startupTask.ExecuteAsync(cancellationToken).ConfigureAwait(false);
|
|
}
|
|
|
|
// Start the tasks as normal
|
|
await webHost.StartAsync(cancellationToken).ConfigureAwait(false);
|
|
}
|
|
}
|
|
}
|