threading fixes
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryWidgetConfigurationChangedHandler :
|
||||
INotificationHandler<ConfigurationChanged<PrimaryWidgetConfiguration>>
|
||||
{
|
||||
private readonly IMediator mediator;
|
||||
private readonly IEnumerable<IWidgetComponentViewModel> items;
|
||||
|
||||
public PrimaryWidgetConfigurationChangedHandler(IMediator mediator,
|
||||
IEnumerable<IWidgetComponentViewModel> items)
|
||||
{
|
||||
this.mediator = mediator;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public async ValueTask Handle(ConfigurationChanged<PrimaryWidgetConfiguration> notification,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
await mediator.PublishAsync(new CollectionChanged<IEnumerable<IWidgetComponentViewModel>>(items),
|
||||
cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@ public class PrimaryWidgetProvider :
|
||||
IWidgetProvider
|
||||
{
|
||||
public void Create(HostBuilderContext comtext, IServiceCollection services) =>
|
||||
services.AddConfiguration(comtext.Configuration.GetSection(nameof(PrimaryWidgetConfiguration)),
|
||||
PrimaryWidgetConfiguration.Defaults)
|
||||
.AddHandler<WidgetComponentMappingHandler>()
|
||||
services.AddConfiguration< PrimaryWidgetConfiguration>(comtext.Configuration.GetSection(nameof(PrimaryWidgetConfiguration)))
|
||||
.AddHandler<WidgetComponentMapping>()
|
||||
.AddHandler<PrimaryWidgetConfigurationChangedHandler>()
|
||||
.AddWidgetTemplate<PrimaryWidgetViewModel>();
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryWidgetViewModel :
|
||||
ObservableCollectionViewModel<IWidgetComponentViewModel>,
|
||||
@@ -7,7 +8,8 @@ public class PrimaryWidgetViewModel :
|
||||
{
|
||||
public PrimaryWidgetViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IEnumerable<IWidgetComponentViewModel> items) : base(serviceFactory, items)
|
||||
IMediator mediator,
|
||||
IEnumerable<IWidgetComponentViewModel> items) : base(serviceFactory, mediator, items)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class WidgetComponentMappingHandler(PrimaryWidgetConfiguration configuration,
|
||||
public class WidgetComponentMapping(PrimaryWidgetConfiguration configuration,
|
||||
IServiceFactory service,
|
||||
IMediator mediator) :
|
||||
IMappingHandler<PrimaryWidgetConfiguration, IEnumerable<IWidgetComponentViewModel>>
|
||||
{
|
||||
public IEnumerable<IWidgetComponentViewModel> Map()
|
||||
public IEnumerable<IWidgetComponentViewModel> Handle()
|
||||
{
|
||||
foreach (IPrimaryCommandConfiguration item in configuration)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user