lots of tidying up

This commit is contained in:
TheXamlGuy
2024-01-25 20:33:55 +00:00
parent 5e26e97f6b
commit a322893166
20 changed files with 115 additions and 123 deletions
+10 -6
View File
@@ -1,7 +1,8 @@
namespace Hyperbar.Widget;
using Microsoft.Extensions.DependencyInjection;
public class WidgetHostHandler(IMediator mediator,
IFactory<IWidgetHost, WidgetContainerViewModel?> factory) :
namespace Hyperbar.Widget;
public class WidgetHostHandler(IMediator mediator) :
INotificationHandler<Started<IWidgetHost>>,
INotificationHandler<Stopped<IWidgetHost>>
{
@@ -10,10 +11,13 @@ public class WidgetHostHandler(IMediator mediator,
{
if (notification.Value is IWidgetHost host)
{
if (factory.Create(host) is WidgetContainerViewModel containerViewModel)
if (host.Services.GetRequiredService<IFactory<IWidgetHost, WidgetContainerViewModel?>>() is { } factory)
{
await mediator.PublishAsync(new Created<WidgetContainerViewModel>(containerViewModel),
nameof(WidgetBarViewModel), cancellationToken);
if (factory.Create(host) is WidgetContainerViewModel containerViewModel)
{
await mediator.PublishAsync(new Created<WidgetContainerViewModel>(containerViewModel),
nameof(WidgetBarViewModel), cancellationToken);
}
}
}
}