Add per plugin json configuration support from a single file
This commit is contained in:
@@ -5,8 +5,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
|
||||
public class AppInitializer([FromKeyedServices(nameof(CommandView))] CommandView view,
|
||||
[FromKeyedServices(nameof(CommandView))] CommandViewModel viewModel,
|
||||
public class AppInitializer([FromKeyedServices(nameof(CommandViewModel))] CommandView view,
|
||||
[FromKeyedServices(nameof(CommandViewModel))] CommandViewModel viewModel,
|
||||
DesktopFlyout desktopFlyout) :
|
||||
IInitializer
|
||||
{
|
||||
|
||||
@@ -7,19 +7,19 @@ namespace Hyperbar.Desktop
|
||||
{
|
||||
public static class IServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddCommandBuilder<TCommandBuilder>(this IServiceCollection services,
|
||||
public static IServiceCollection AddCommand<TCommandBuilder>(this IServiceCollection services,
|
||||
string key)
|
||||
where TCommandBuilder :
|
||||
ICommandBuilder, new()
|
||||
{
|
||||
TCommandBuilder builder = new();
|
||||
IHost? host = new HostBuilder()
|
||||
.ConfigureServices(services =>
|
||||
.ConfigureServices(isolatedServices =>
|
||||
{
|
||||
services.AddTransient<ITemplateFactory, TemplateFactory>();
|
||||
services.AddTransient<ITemplateGeneratorFactory, TemplateGeneratorFactory>();
|
||||
isolatedServices.AddTransient<ITemplateFactory, TemplateFactory>();
|
||||
isolatedServices.AddTransient<ITemplateGeneratorFactory, TemplateGeneratorFactory>();
|
||||
|
||||
builder.Create(services);
|
||||
builder.Create(isolatedServices);
|
||||
}).Build();
|
||||
|
||||
services.AddTransient<ICommandContext>(provider => new CommandContext(host.Services));
|
||||
|
||||
Reference in New Issue
Block a user