Add per plugin json configuration support from a single file

This commit is contained in:
TheXamlGuy
2024-01-05 21:54:48 +00:00
parent e180c966ff
commit b380f06fbf
30 changed files with 277 additions and 541 deletions
@@ -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));