This commit is contained in:
TheXamlGuy
2024-02-10 20:19:01 +00:00
parent ecfac99868
commit 565c6866d8
60 changed files with 445 additions and 381 deletions
@@ -1,8 +1,6 @@
using Hyperbar.Widget;
namespace Hyperbar.Widget.Primary.Windows;
namespace Hyperbar.Widget.Primary.Windows;
public class PrimaryWidgetConfigurationHandler(IMediator mediator,
public class PrimaryWidgetConfigurationHandler(IPublisher publisher,
PrimaryWidgetConfiguration configuration,
IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?> factory,
IProvider<PrimaryCommandConfiguration, IWidgetComponentViewModel?> provider,
@@ -44,7 +42,7 @@ public class PrimaryWidgetConfigurationHandler(IMediator mediator,
if (moved.Value is PrimaryCommandConfiguration configuration &&
provider.Get(configuration) is IWidgetComponentViewModel viewModel)
{
await mediator.PublishAsync(new Move<IWidgetComponentViewModel>(configuration.Order, viewModel),
await publisher.PublishAsync(new Move<IWidgetComponentViewModel>(configuration.Order, viewModel),
moved.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : moved.Key.ParentId,
cancellationToken);
@@ -61,8 +59,7 @@ public class PrimaryWidgetConfigurationHandler(IMediator mediator,
if (added.Value is PrimaryCommandConfiguration configuration &&
factory.Create(configuration) is IWidgetComponentViewModel viewModel)
{
await mediator.PublishAsync(
new Insert<IWidgetComponentViewModel>(configuration.Order, viewModel),
await publisher.PublishAsync(new Insert<IWidgetComponentViewModel>(configuration.Order, viewModel),
added.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : added.Key.ParentId,
cancellationToken);
@@ -78,8 +75,7 @@ public class PrimaryWidgetConfigurationHandler(IMediator mediator,
if (removed.Value is PrimaryCommandConfiguration configuration &&
provider.Get(configuration) is IWidgetComponentViewModel viewModel)
{
await mediator.PublishAsync(
new Remove<IWidgetComponentViewModel>(viewModel),
await publisher.PublishAsync(new Remove<IWidgetComponentViewModel>(viewModel),
removed.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : removed.Key.ParentId,
cancellationToken);
@@ -5,7 +5,8 @@ namespace Hyperbar.Widget.Primary.Windows;
[NotificationHandler(nameof(PrimaryWidgetViewModel))]
public class PrimaryWidgetViewModel(IServiceProvider serviceProvider,
IServiceFactory serviceFactory,
IMediator mediator,
IPublisher publisher,
ISubscriber subscriber,
IDisposer disposer) :
ObservableCollectionViewModel<IWidgetComponentViewModel>(serviceProvider, serviceFactory, mediator, disposer),
ObservableCollectionViewModel<IWidgetComponentViewModel>(serviceProvider, serviceFactory, publisher, subscriber, disposer),
IWidgetViewModel;
@@ -1,14 +1,13 @@
using Hyperbar.Widget;
namespace Hyperbar.Widget.Primary.Windows;
namespace Hyperbar.Widget.Primary.Windows;
public class WidgetComponentViewModelEnumerator(PrimaryWidgetConfiguration configuration,
IMediator mediator,
IPublisher publisher,
IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?> factory,
ICache<(Guid ParentId, Guid Id), PrimaryCommandConfiguration> cache) :
INotificationHandler<Enumerate<IWidgetComponentViewModel>>
{
public async Task Handle(Enumerate<IWidgetComponentViewModel> notification, CancellationToken cancellationToken)
public async Task Handle(Enumerate<IWidgetComponentViewModel> notification,
CancellationToken cancellationToken)
{
Stack<(Guid, List<PrimaryCommandConfiguration>)> stack = new();
stack.Push((Guid.Empty, configuration.Commands));
@@ -30,7 +29,7 @@ public class WidgetComponentViewModelEnumerator(PrimaryWidgetConfiguration confi
{
if (factory.Create(item) is IWidgetComponentViewModel viewModel)
{
await mediator.PublishAsync(new Create<IWidgetComponentViewModel>(viewModel), nameof(PrimaryWidgetViewModel),
await publisher.PublishAsync(new Create<IWidgetComponentViewModel>(viewModel), nameof(PrimaryWidgetViewModel),
cancellationToken);
}
}