fixed fetching configuration from root

This commit is contained in:
TheXamlGuy
2024-01-07 13:18:38 +00:00
parent 28af62d72d
commit d86c5da7a9
5 changed files with 18 additions and 14 deletions
@@ -5,6 +5,6 @@ public class PrimaryWidgetConfiguration :
{
public static PrimaryWidgetConfiguration Defaults => new()
{
new KeyAcceleratorCommandConfiguration { Icon = "Test", Key = "Test", Modifiers = ["Test", "Test"] }
new KeyAcceleratorCommandConfiguration { Icon = "\uE720", Key = "Test", Modifiers = ["Test", "Test"] }
};
}
@@ -5,21 +5,26 @@ public class WidgetComponentMappingFactory :
{
private readonly PrimaryWidgetConfiguration configuration;
private readonly IServiceFactory service;
private readonly IMediator mediator;
public WidgetComponentMappingFactory(PrimaryWidgetConfiguration configuration,
IServiceFactory service)
IServiceFactory service,
IMediator mediator)
{
this.configuration = configuration;
this.service = service;
this.mediator = mediator;
}
public IEnumerable<IWidgetComponentViewModel> Create()
{
foreach (IPrimaryCommandConfiguration item in configuration)
{
if (item is KeyAcceleratorCommandConfiguration keyAcceleratorCommand)
{
yield return service.Create<WidgetButtonViewModel>(keyAcceleratorCommand.Icon, new Action(() =>
mediator.Send(new KeyAcceleratorCommand(VirtualKey.LeftWindows))));
}
}
return Enumerable.Empty<IWidgetComponentViewModel>();
}
}