fixed fetching configuration from root
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return Enumerable.Empty<IWidgetComponentViewModel>();
|
||||
if (item is KeyAcceleratorCommandConfiguration keyAcceleratorCommand)
|
||||
{
|
||||
yield return service.Create<WidgetButtonViewModel>(keyAcceleratorCommand.Icon, new Action(() =>
|
||||
mediator.Send(new KeyAcceleratorCommand(VirtualKey.LeftWindows))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using Hyperbar.Extensions;
|
||||
using Hyperbar.Windows.Interop;
|
||||
using Hyperbar.Windows.Primary;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Hyperbar.Windows
|
||||
{
|
||||
@@ -45,11 +43,8 @@ namespace Hyperbar.Windows
|
||||
builder.Create(context, isolatedServices);
|
||||
}).Build();
|
||||
|
||||
|
||||
services.AddTransient<IWidgetContext>(provider => new WidgetContext(host.Services));
|
||||
host.Start();
|
||||
|
||||
var d = host.Services.GetService<IOptionsMonitor<PrimaryWidgetConfiguration>>();
|
||||
services.AddTransient(provider => host);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -9,12 +9,15 @@
|
||||
<SolidColorBrush x:Key="ButtonBorderBrushPointerOver" Color="Transparent" />
|
||||
<SolidColorBrush x:Key="ButtonBorderBrushPressed" Color="Transparent" />
|
||||
<SolidColorBrush x:Key="ButtonBorderBrushDisabled" Color="Transparent" />
|
||||
<Thickness x:Key="ButtonPadding">0</Thickness>
|
||||
<x:Double x:Key="ButtonWidth">32</x:Double>
|
||||
<x:Double x:Key="ButtonHeight">32</x:Double>
|
||||
</UserControl.Resources>
|
||||
<Button
|
||||
Width="{StaticResource ButtonWidth}"
|
||||
Height="{StaticResource ButtonHeight}"
|
||||
Padding="0"
|
||||
Command="{Binding Click}"
|
||||
Content="{Binding Icon}" />
|
||||
Content="{Binding Icon}"
|
||||
FontFamily="{StaticResource SymbolThemeFontFamily}" />
|
||||
</UserControl>
|
||||
@@ -106,8 +106,9 @@ public static class IServiceCollectionExtensions
|
||||
{
|
||||
services.Configure<TConfiguration>(configuration);
|
||||
services.AddSingleton<IConfigureOptions<TConfiguration>>(new ConfigureNamedOptions<TConfiguration>("", args => { }));
|
||||
services.AddTransient(provider => provider.GetService<IOptionsMonitor<TConfiguration>>()!.CurrentValue);
|
||||
services.AddTransient(provider => {
|
||||
|
||||
return provider.GetService<IOptionsMonitor<TConfiguration>>()!.CurrentValue; });
|
||||
|
||||
services.AddSingleton<IConfigurationWriter<TConfiguration>>(provider =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user