More configuration work
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryWidgetConfiguration :
|
||||
List<IPrimaryCommandConfiguration>
|
||||
List<KeyAcceleratorCommandConfiguration>
|
||||
{
|
||||
public static PrimaryWidgetConfiguration Defaults => new()
|
||||
{
|
||||
new KeyAcceleratorCommandConfiguration { Icon = "Test", Key = "Test", Modifiers = ["Test", "Test"] }
|
||||
};
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
using Hyperbar.Extensions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryWidgetProvider :
|
||||
IWidgetProvider
|
||||
{
|
||||
public void Create(IServiceCollection services) => services.AddConfiguration<PrimaryWidgetConfiguration>()
|
||||
.AddTransient<WidgetComponentMappinglFactory>()
|
||||
.AddTransient(provider => provider.GetRequiredService<WidgetComponentMappinglFactory>().Create())
|
||||
public void Create(HostBuilderContext comtext, IServiceCollection services) =>
|
||||
services.AddConfiguration(comtext.Configuration.GetSection(nameof(PrimaryWidgetConfiguration)),
|
||||
PrimaryWidgetConfiguration.Defaults)
|
||||
.AddTransient<WidgetComponentMappingFactory>()
|
||||
.AddTransient(provider => provider.GetRequiredService<WidgetComponentMappingFactory>().Create())
|
||||
.AddWidgetTemplate<PrimaryWidgetViewModel>();
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class WidgetComponentMappinglFactory :
|
||||
MappingFactory<PrimaryWidgetConfiguration, IEnumerable<IWidgetComponentViewModel>>
|
||||
public class WidgetComponentMappingFactory :
|
||||
IMappingFactory<PrimaryWidgetConfiguration, IEnumerable<IWidgetComponentViewModel>>
|
||||
{
|
||||
private readonly PrimaryWidgetConfiguration configuration;
|
||||
private readonly IServiceFactory service;
|
||||
|
||||
public WidgetComponentMappinglFactory(PrimaryWidgetConfiguration configuration,
|
||||
public WidgetComponentMappingFactory(PrimaryWidgetConfiguration configuration,
|
||||
IServiceFactory service)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
|
||||
Reference in New Issue
Block a user