From 4766ed115687a008dd79973fb020e5e6762235c7 Mon Sep 17 00:00:00 2001 From: TheXamlGuy Date: Thu, 18 Jan 2024 23:55:02 +0000 Subject: [PATCH] wip --- .../PrimaryWidgetProvider.cs | 16 ++++++++-------- Hyperbar.Windows/App.xaml.cs | 2 +- .../Lifecycles/IServiceCollectionExtensions.cs | 2 +- Hyperbar/Widgets/IWidgetContext.cs | 6 ------ Hyperbar/Widgets/WidgetConfiguration.cs | 10 ++++++++++ Hyperbar/Widgets/WidgetContext.cs | 3 +-- Hyperbar/Widgets/WidgetService.cs | 2 +- 7 files changed, 22 insertions(+), 19 deletions(-) delete mode 100644 Hyperbar/Widgets/IWidgetContext.cs create mode 100644 Hyperbar/Widgets/WidgetConfiguration.cs diff --git a/Hyperbar.Windows.Primary/PrimaryWidgetProvider.cs b/Hyperbar.Windows.Primary/PrimaryWidgetProvider.cs index 5b75b92..2d2cb44 100644 --- a/Hyperbar.Windows.Primary/PrimaryWidgetProvider.cs +++ b/Hyperbar.Windows.Primary/PrimaryWidgetProvider.cs @@ -7,13 +7,13 @@ public class PrimaryWidgetProvider : IWidgetProvider { public void Create(HostBuilderContext comtext, IServiceCollection services) => - services.AddConfiguration() - .AddCache<(Guid ParentId, Guid Id), PrimaryCommandConfiguration>() - .AddCache() - .AddTransient, WidgetComponentViewModelProvider>() - .AddTransient, WidgetComponentViewModelFactory>() - .AddTransient, WidgetComponentViewModelEnumerator>() - .AddWidgetTemplate() - .AddHandler(); + services.AddConfiguration() + .AddCache<(Guid ParentId, Guid Id), PrimaryCommandConfiguration>() + .AddCache() + .AddTransient, WidgetComponentViewModelProvider>() + .AddTransient, WidgetComponentViewModelFactory>() + .AddTransient, WidgetComponentViewModelEnumerator>() + .AddWidgetTemplate() + .AddHandler(); } \ No newline at end of file diff --git a/Hyperbar.Windows/App.xaml.cs b/Hyperbar.Windows/App.xaml.cs index 247b4c2..38be66e 100644 --- a/Hyperbar.Windows/App.xaml.cs +++ b/Hyperbar.Windows/App.xaml.cs @@ -60,7 +60,7 @@ public partial class App : static IEnumerable Resolve(IServiceProvider services) { int index = 0; - foreach (IWidgetContext widgetContext in services.GetServices()) + foreach (WidgetContext widgetContext in services.GetServices()) { if (widgetContext.ServiceProvider.GetServices() is IEnumerable viewModels) diff --git a/Hyperbar.Windows/Lifecycles/IServiceCollectionExtensions.cs b/Hyperbar.Windows/Lifecycles/IServiceCollectionExtensions.cs index c4323d9..f13ebbd 100644 --- a/Hyperbar.Windows/Lifecycles/IServiceCollectionExtensions.cs +++ b/Hyperbar.Windows/Lifecycles/IServiceCollectionExtensions.cs @@ -54,7 +54,7 @@ namespace Hyperbar.Windows }).Build(); - services.AddTransient(provider => new WidgetContext(host.Services)); + services.AddTransient(provider => new WidgetContext(host.Services)); host.Start(); return services; diff --git a/Hyperbar/Widgets/IWidgetContext.cs b/Hyperbar/Widgets/IWidgetContext.cs deleted file mode 100644 index 17919b0..0000000 --- a/Hyperbar/Widgets/IWidgetContext.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Hyperbar; - -public interface IWidgetContext -{ - IServiceProvider ServiceProvider { get; } -} \ No newline at end of file diff --git a/Hyperbar/Widgets/WidgetConfiguration.cs b/Hyperbar/Widgets/WidgetConfiguration.cs new file mode 100644 index 0000000..2993e25 --- /dev/null +++ b/Hyperbar/Widgets/WidgetConfiguration.cs @@ -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; } +} diff --git a/Hyperbar/Widgets/WidgetContext.cs b/Hyperbar/Widgets/WidgetContext.cs index 9e5cf65..c7a875a 100644 --- a/Hyperbar/Widgets/WidgetContext.cs +++ b/Hyperbar/Widgets/WidgetContext.cs @@ -1,7 +1,6 @@ namespace Hyperbar; -public class WidgetContext(IServiceProvider serviceProvider) : - IWidgetContext +public sealed class WidgetContext(IServiceProvider serviceProvider) { public IServiceProvider ServiceProvider => serviceProvider; } \ No newline at end of file diff --git a/Hyperbar/Widgets/WidgetService.cs b/Hyperbar/Widgets/WidgetService.cs index c4a662b..f1ad9da 100644 --- a/Hyperbar/Widgets/WidgetService.cs +++ b/Hyperbar/Widgets/WidgetService.cs @@ -2,7 +2,7 @@ namespace Hyperbar; -public class WidgetService(IEnumerable initializers) : +public sealed class WidgetService(IEnumerable initializers) : IHostedService { public async Task StartAsync(CancellationToken cancellationToken)