reduce mediator duffs
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class WidgetComponentMappingHandler(PrimaryWidgetConfiguration configuration,
|
||||
IServiceFactory service,
|
||||
IMediator mediator) :
|
||||
IMappingHandler<PrimaryWidgetConfiguration, IEnumerable<IWidgetComponentViewModel>>
|
||||
{
|
||||
public IEnumerable<IWidgetComponentViewModel> Handle()
|
||||
{
|
||||
foreach (IPrimaryCommandConfiguration item in configuration)
|
||||
{
|
||||
if (item is KeyAcceleratorCommandConfiguration keyAcceleratorCommand)
|
||||
{
|
||||
yield return service.Create<WidgetButtonViewModel>(keyAcceleratorCommand.Icon, new Action(async () =>
|
||||
await mediator.SendAsync(new KeyAcceleratorCommand(VirtualKey.LeftWindows))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user