wip
This commit is contained in:
@@ -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>();
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public interface IWidgetContext
|
||||
{
|
||||
IServiceProvider ServiceProvider { get; }
|
||||
}
|
||||
@@ -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,7 +1,6 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public class WidgetContext(IServiceProvider serviceProvider) :
|
||||
IWidgetContext
|
||||
public sealed class WidgetContext(IServiceProvider serviceProvider)
|
||||
{
|
||||
public IServiceProvider ServiceProvider => serviceProvider;
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user