more refoctoring work
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryWidget :
|
||||
IWidget
|
||||
{
|
||||
public IWidgetBuilder Create() =>
|
||||
WidgetBuilder.Configure<PrimaryWidgetConfiguration>(args =>
|
||||
{
|
||||
args.Id = Guid.Parse("cfdfe07c-d9d6-4174-ae41-988ca24d2e10");
|
||||
args.Name = "Primary commands";
|
||||
|
||||
}).ConfigureServices(args =>
|
||||
{
|
||||
args.AddCache<(Guid ParentId, Guid Id), PrimaryCommandConfiguration>()
|
||||
.AddCache<Guid, IWidgetComponentViewModel>()
|
||||
.AddTransient<IProvider<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentProvider>()
|
||||
.AddTransient<IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentFactory>()
|
||||
.AddTransient<IEnumerator<IWidgetComponentViewModel>, WidgetComponentEnumerator>()
|
||||
.AddWidgetTemplate<PrimaryWidgetViewModel>()
|
||||
.AddHandler<PrimaryWidgetConfigurationHandler>();
|
||||
});
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryWidgetConfiguration
|
||||
public class PrimaryWidgetConfiguration : WidgetConfiguration
|
||||
{
|
||||
public List<PrimaryCommandConfiguration> Commands { get; set; } = [];
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryWidgetConfigurationBuilder :
|
||||
IWidgetBuilder
|
||||
{
|
||||
public void Create(IServiceCollection services) =>
|
||||
WidgetBuilder.Config(services, config =>
|
||||
{
|
||||
config.Id = Guid.Parse("cfdfe07c-d9d6-4174-ae41-988ca24d2e10");
|
||||
config.Name = "Primary commands";
|
||||
|
||||
services.AddConfiguration<PrimaryWidgetConfiguration>()
|
||||
.AddCache<(Guid ParentId, Guid Id), PrimaryCommandConfiguration>()
|
||||
.AddCache<Guid, IWidgetComponentViewModel>()
|
||||
.AddTransient<IProvider<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentViewModelProvider>()
|
||||
.AddTransient<IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?>, WidgetComponentViewModelFactory>()
|
||||
.AddTransient<IViewModelEnumerator<IWidgetComponentViewModel>, WidgetComponentViewModelEnumerator>()
|
||||
.AddWidgetTemplate<PrimaryWidgetViewModel>()
|
||||
.AddHandler<PrimaryWidgetConfigurationHandler>();
|
||||
});
|
||||
}
|
||||
@@ -5,7 +5,7 @@ public class PrimaryWidgetViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer,
|
||||
IViewModelEnumerator<IWidgetComponentViewModel> enumerator) :
|
||||
IEnumerator<IWidgetComponentViewModel> enumerator) :
|
||||
ObservableCollectionViewModel<IWidgetComponentViewModel>(serviceFactory, mediator, disposer, enumerator),
|
||||
IWidgetViewModel,
|
||||
ITemplatedViewModel
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class WidgetComponentViewModelEnumerator(PrimaryWidgetConfiguration configuration,
|
||||
public class WidgetComponentEnumerator(PrimaryWidgetConfiguration configuration,
|
||||
IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?> factory,
|
||||
ICache<(Guid ParentId, Guid Id), PrimaryCommandConfiguration> cache) :
|
||||
IViewModelEnumerator<IWidgetComponentViewModel>
|
||||
IEnumerator<IWidgetComponentViewModel>
|
||||
{
|
||||
public IEnumerable<IWidgetComponentViewModel?> Next()
|
||||
{
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class WidgetComponentViewModelFactory(IServiceFactory service,
|
||||
public class WidgetComponentFactory(IServiceFactory service,
|
||||
IMediator mediator,
|
||||
ICache<Guid, IWidgetComponentViewModel> cache) :
|
||||
IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?>
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class WidgetComponentViewModelProvider(ICache<Guid, IWidgetComponentViewModel> cache) :
|
||||
public class WidgetComponentProvider(ICache<Guid, IWidgetComponentViewModel> cache) :
|
||||
IProvider<PrimaryCommandConfiguration, IWidgetComponentViewModel?>
|
||||
{
|
||||
public IWidgetComponentViewModel? Get(PrimaryCommandConfiguration value)
|
||||
Reference in New Issue
Block a user