restructure project for part 2

This commit is contained in:
TheXamlGuy
2024-01-27 10:55:53 +00:00
parent a322893166
commit 48925b89ff
96 changed files with 383 additions and 351 deletions
@@ -0,0 +1,32 @@
using Microsoft.Extensions.DependencyInjection;
namespace Hyperbar.Widget.MediaController.Windows;
public class MediaControllerHandler(IMediator mediator,
IServiceScopeProvider<MediaController> scopeProvider,
ICache<MediaController, MediaControllerViewModel> cache) :
INotificationHandler<Created<MediaController>>
{
public async Task Handle(Created<MediaController> notification,
CancellationToken cancellationToken)
{
if (notification.Value is MediaController mediaController)
{
if (scopeProvider.TryGet(mediaController, out IServiceScope? serviceScope))
if (serviceScope is not null)
{
if (serviceScope.ServiceProvider.GetService<IFactory<MediaController, MediaControllerViewModel?>>()
is IFactory<MediaController, MediaControllerViewModel?> factory)
{
if (factory.Create(mediaController) is MediaControllerViewModel mediaControllerViewModel)
{
cache.Add(mediaController, mediaControllerViewModel);
//await mediator.PublishAsync(new Created<MediaControllerViewModel>(mediaControllerViewModel),
// cancellationToken);
}
}
}
}
}
}