using Microsoft.Extensions.DependencyInjection; namespace Hyperbar.Widget; public class WidgetHostHandler(IMediator mediator) : INotificationHandler>, INotificationHandler> { public async Task Handle(Started notification, CancellationToken cancellationToken) { if (notification.Value is IWidgetHost host) { if (host.Services.GetRequiredService>() is { } factory) { if (factory.Create(host) is WidgetContainerViewModel containerViewModel) { await mediator.PublishAsync(new Created(containerViewModel), nameof(WidgetBarViewModel), cancellationToken); } } } } public Task Handle(Stopped notification, CancellationToken cancellationToken) { throw new NotImplementedException(); } }