mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 05:54:26 +01:00
* BTCPay Extensions Part 2 This PR cleans up the extension system a bit in that: * It renames the test extension to a more uniform name * Allows yo uto have system extensions, which are extensions but bundled by default with the release (and cannot be removed) * Adds a tool to help you generate an extension package from a csproj * Refactors the UI extension points to a view component * Moves some more interfaces to the Abstractions csproj * Rename to plugins
45 lines
1.7 KiB
C#
45 lines
1.7 KiB
C#
using System.Linq;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace BTCPayServer.Plugins.Test
|
|
{
|
|
public class ApplicationPartsLogger : IHostedService
|
|
{
|
|
private readonly ILogger<ApplicationPartsLogger> _logger;
|
|
private readonly ApplicationPartManager _partManager;
|
|
|
|
public ApplicationPartsLogger(ILogger<ApplicationPartsLogger> logger, ApplicationPartManager partManager)
|
|
{
|
|
_logger = logger;
|
|
_partManager = partManager;
|
|
}
|
|
|
|
public Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
// Get the names of all the application parts. This is the short assembly name for AssemblyParts
|
|
var applicationParts = _partManager.ApplicationParts.Select(x => x.Name);
|
|
|
|
// Create a controller feature, and populate it from the application parts
|
|
var controllerFeature = new ControllerFeature();
|
|
_partManager.PopulateFeature(controllerFeature);
|
|
|
|
// Get the names of all of the controllers
|
|
var controllers = controllerFeature.Controllers.Select(x => x.Name);
|
|
|
|
// Log the application parts and controllers
|
|
_logger.LogInformation("Found the following application parts: '{ApplicationParts}' with the following controllers: '{Controllers}'",
|
|
string.Join(", ", applicationParts), string.Join(", ", controllers));
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
// Required by the interface
|
|
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
|
}
|
|
}
|