wip
This commit is contained in:
@@ -7,13 +7,13 @@ public class PrimaryWidgetProvider :
|
|||||||
IWidgetProvider
|
IWidgetProvider
|
||||||
{
|
{
|
||||||
public void Create(HostBuilderContext comtext, IServiceCollection services) =>
|
public void Create(HostBuilderContext comtext, IServiceCollection services) =>
|
||||||
services.AddConfiguration<PrimaryWidgetConfiguration>()
|
services.AddConfiguration<PrimaryWidgetConfiguration>()
|
||||||
.AddCache<(Guid ParentId, Guid Id), PrimaryCommandConfiguration>()
|
.AddCache<(Guid ParentId, Guid Id), PrimaryCommandConfiguration>()
|
||||||
.AddCache<Guid, IWidgetComponentViewModel>()
|
.AddCache<Guid, IWidgetComponentViewModel>()
|
||||||
.AddTransient<IProvider<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentViewModelProvider>()
|
.AddTransient<IProvider<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentViewModelProvider>()
|
||||||
.AddTransient<IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentViewModelFactory>()
|
.AddTransient<IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentViewModelFactory>()
|
||||||
.AddTransient<IViewModelEnumerator<IWidgetComponentViewModel>, WidgetComponentViewModelEnumerator>()
|
.AddTransient<IViewModelEnumerator<IWidgetComponentViewModel>, WidgetComponentViewModelEnumerator>()
|
||||||
.AddWidgetTemplate<PrimaryWidgetViewModel>()
|
.AddWidgetTemplate<PrimaryWidgetViewModel>()
|
||||||
.AddHandler<PrimaryWidgetConfigurationHandler>();
|
.AddHandler<PrimaryWidgetConfigurationHandler>();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ public partial class App :
|
|||||||
static IEnumerable<WidgetContainerViewModel> Resolve(IServiceProvider services)
|
static IEnumerable<WidgetContainerViewModel> Resolve(IServiceProvider services)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
foreach (IWidgetContext widgetContext in services.GetServices<IWidgetContext>())
|
foreach (WidgetContext widgetContext in services.GetServices<WidgetContext>())
|
||||||
{
|
{
|
||||||
if (widgetContext.ServiceProvider.GetServices<IWidgetViewModel>() is
|
if (widgetContext.ServiceProvider.GetServices<IWidgetViewModel>() is
|
||||||
IEnumerable<IWidgetViewModel> viewModels)
|
IEnumerable<IWidgetViewModel> viewModels)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace Hyperbar.Windows
|
|||||||
|
|
||||||
}).Build();
|
}).Build();
|
||||||
|
|
||||||
services.AddTransient<IWidgetContext>(provider => new WidgetContext(host.Services));
|
services.AddTransient(provider => new WidgetContext(host.Services));
|
||||||
|
|
||||||
host.Start();
|
host.Start();
|
||||||
return services;
|
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;
|
namespace Hyperbar;
|
||||||
|
|
||||||
public class WidgetContext(IServiceProvider serviceProvider) :
|
public sealed class WidgetContext(IServiceProvider serviceProvider)
|
||||||
IWidgetContext
|
|
||||||
{
|
{
|
||||||
public IServiceProvider ServiceProvider => serviceProvider;
|
public IServiceProvider ServiceProvider => serviceProvider;
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar;
|
||||||
|
|
||||||
public class WidgetService(IEnumerable<IInitializer> initializers) :
|
public sealed class WidgetService(IEnumerable<IInitializer> initializers) :
|
||||||
IHostedService
|
IHostedService
|
||||||
{
|
{
|
||||||
public async Task StartAsync(CancellationToken cancellationToken)
|
public async Task StartAsync(CancellationToken cancellationToken)
|
||||||
|
|||||||
Reference in New Issue
Block a user