This commit is contained in:
TheXamlGuy
2024-01-18 23:55:02 +00:00
parent a0042a5299
commit 4766ed1156
7 changed files with 22 additions and 19 deletions
@@ -7,13 +7,13 @@ public class PrimaryWidgetProvider :
IWidgetProvider
{
public void Create(HostBuilderContext comtext, IServiceCollection services) =>
services.AddConfiguration<PrimaryWidgetConfiguration>()
.AddCache<(Guid ParentId, Guid Id), PrimaryCommandConfiguration>()
.AddCache<Guid, IWidgetComponentViewModel>()
.AddTransient<IProvider<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentViewModelProvider>()
.AddTransient<IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentViewModelFactory>()
.AddTransient<IViewModelEnumerator<IWidgetComponentViewModel>, WidgetComponentViewModelEnumerator>()
.AddWidgetTemplate<PrimaryWidgetViewModel>()
.AddHandler<PrimaryWidgetConfigurationHandler>();
services.AddConfiguration<PrimaryWidgetConfiguration>()
.AddCache<(Guid ParentId, Guid Id), PrimaryCommandConfiguration>()
.AddCache<Guid, IWidgetComponentViewModel>()
.AddTransient<IProvider<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentViewModelProvider>()
.AddTransient<IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentViewModelFactory>()
.AddTransient<IViewModelEnumerator<IWidgetComponentViewModel>, WidgetComponentViewModelEnumerator>()
.AddWidgetTemplate<PrimaryWidgetViewModel>()
.AddHandler<PrimaryWidgetConfigurationHandler>();
}
+1 -1
View File
@@ -60,7 +60,7 @@ public partial class App :
static IEnumerable<WidgetContainerViewModel> Resolve(IServiceProvider services)
{
int index = 0;
foreach (IWidgetContext widgetContext in services.GetServices<IWidgetContext>())
foreach (WidgetContext widgetContext in services.GetServices<WidgetContext>())
{
if (widgetContext.ServiceProvider.GetServices<IWidgetViewModel>() is
IEnumerable<IWidgetViewModel> viewModels)
@@ -54,7 +54,7 @@ namespace Hyperbar.Windows
}).Build();
services.AddTransient<IWidgetContext>(provider => new WidgetContext(host.Services));
services.AddTransient(provider => new WidgetContext(host.Services));
host.Start();
return services;
-6
View File
@@ -1,6 +0,0 @@
namespace Hyperbar;
public interface IWidgetContext
{
IServiceProvider ServiceProvider { get; }
}
+10
View File
@@ -0,0 +1,10 @@
namespace Hyperbar;
public sealed class WidgetConfiguration
{
public required Guid Id { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
}
+1 -2
View File
@@ -1,7 +1,6 @@
namespace Hyperbar;
public class WidgetContext(IServiceProvider serviceProvider) :
IWidgetContext
public sealed class WidgetContext(IServiceProvider serviceProvider)
{
public IServiceProvider ServiceProvider => serviceProvider;
}
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Hyperbar;
public class WidgetService(IEnumerable<IInitializer> initializers) :
public sealed class WidgetService(IEnumerable<IInitializer> initializers) :
IHostedService
{
public async Task StartAsync(CancellationToken cancellationToken)