WIP
This commit is contained in:
@@ -111,11 +111,7 @@ public partial class App : Application
|
||||
services.AddTemplate<LockerViewModel, LockerView>("Locker");
|
||||
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
||||
|
||||
services.AddSingleton<IDecoratorService<ICollectionSynchronization<ItemNavigationViewModel>>,
|
||||
DecoratorService<ICollectionSynchronization<ItemNavigationViewModel>>>();
|
||||
services.AddTransient(provider => provider.GetRequiredService<IDecoratorService<ICollectionSynchronization<ItemNavigationViewModel>>>().Value!);
|
||||
|
||||
services.AddHandler<AggerateItemViewModelHandler>();
|
||||
services.AddHandler<SynchronizeItemViewModelHandler>();
|
||||
|
||||
services.AddTemplate<LockerHeaderViewModel, LockerHeaderView>("LockerHeader");
|
||||
services.AddTemplate<BackActionViewModel, BackActionView>();
|
||||
@@ -125,7 +121,7 @@ public partial class App : Application
|
||||
services.AddTemplate<ItemCategoryCollectionViewModel, ItemCategoryCollectionView>("ItemCategoryCollection");
|
||||
services.AddTemplate<ItemCategoryNavigationViewModel, ItemCategoryNavigationView>();
|
||||
|
||||
services.AddHandler<AggregateItemCategoryViewModelHandler>();
|
||||
services.AddHandler<SynchronizeItemCategoryViewModelHandler>();
|
||||
|
||||
services.AddScoped<IDecoratorService<Item<(Guid, string)>>, DecoratorService<Item<(Guid, string)>>>();
|
||||
|
||||
@@ -137,8 +133,8 @@ public partial class App : Application
|
||||
services.AddTemplate<ItemHeaderViewModel, ItemHeaderView>();
|
||||
services.AddTemplate<ItemContentViewModel, ItemContentView>();
|
||||
|
||||
services.AddHandler<AggregateItemContentViewModelHandler>();
|
||||
services.AddHandler<AggregateItemContentFromCategoryViewModelHandler>();
|
||||
services.AddHandler<SynchronizeItemContentViewModelHandler>();
|
||||
services.AddHandler<SynchronizeItemContentFromCategoryViewModelHandler>();
|
||||
|
||||
services.AddTemplate<ItemSectionViewModel, ItemSectionView>();
|
||||
|
||||
@@ -147,10 +143,6 @@ public partial class App : Application
|
||||
services.AddTemplate<ItemMaskedTextEntryViewModel, ItemMaskedTextEntryView>();
|
||||
services.AddTemplate<ItemDropdownEntryViewModel, ItemDropdownEntryView>();
|
||||
|
||||
services.AddSingleton<IDecoratorService<ICollectionSynchronization<IItemEntryViewModel>>,
|
||||
DecoratorService<ICollectionSynchronization<IItemEntryViewModel>>>();
|
||||
services.AddTransient(provider => provider.GetRequiredService<IDecoratorService<ICollectionSynchronization<IItemEntryViewModel>>>().Value!);
|
||||
|
||||
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
|
||||
|
||||
services.AddTemplate<FavouriteItemActionViewModel, FavouriteItemActionView>();
|
||||
@@ -186,7 +178,7 @@ public partial class App : Application
|
||||
services.AddInitializer<LockerInitializer>();
|
||||
|
||||
services.AddTemplate<MainViewModel, MainView>("Main");
|
||||
services.AddHandler<AggregateMainViewModelHandler>();
|
||||
services.AddHandler<SynchronizeMainViewModelHandler>();
|
||||
|
||||
services.AddTransient<FooterViewModel>();
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggregateItemContentFromCategoryViewModelHandler(IItemConfigurationCollection configurations,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<IItemEntryViewModel, string>>
|
||||
{
|
||||
public async Task Handle(AggerateEventArgs<IItemEntryViewModel, string> args)
|
||||
{
|
||||
if (args.Value is string category)
|
||||
{
|
||||
if (configurations.TryGetValue(category, out Func<ItemConfiguration>? factory))
|
||||
{
|
||||
if (factory.Invoke() is ItemConfiguration configuration)
|
||||
{
|
||||
foreach (ItemSectionConfiguration configurationSection in configuration.Sections)
|
||||
{
|
||||
string section = $"{nameof(ItemSection)}:{Guid.NewGuid}";
|
||||
if (serviceFactory.Create<ItemSectionViewModel>(section)
|
||||
is ItemSectionViewModel sectionViewModel)
|
||||
{
|
||||
publisher.Publish(Create.As(sectionViewModel), nameof(ItemContentViewModel));
|
||||
foreach (ItemEntryConfiguration entryConfiguration in configurationSection.Entries)
|
||||
{
|
||||
if (await mediator.Handle<ItemEntryConfiguration, IItemEntryViewModel?>(entryConfiguration,
|
||||
entryConfiguration.GetType().Name) is IItemEntryViewModel entryViewModel)
|
||||
{
|
||||
publisher.Publish(Create.As(entryViewModel), section);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,9 @@ public class ConfirmCreateItemHandler(IMediator mediator,
|
||||
|
||||
if (name is not null)
|
||||
{
|
||||
IList<(int, string)> sections = await mediator.HandleMany<ConfirmEventArgs<ItemSection>,
|
||||
(int, string)>(Confirm.As<ItemSection>());
|
||||
|
||||
IList<(int, ItemEntryConfiguration)> entries = await mediator.HandleMany<ConfirmEventArgs<ItemContentEntry>,
|
||||
(int, ItemEntryConfiguration)>(Confirm.As<ItemContentEntry>());
|
||||
|
||||
|
||||
@@ -5,13 +5,12 @@ namespace Bitvault;
|
||||
public partial class FooterViewModel :
|
||||
ObservableCollection<IMainNavigationViewModel>
|
||||
{
|
||||
public FooterViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
public FooterViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : base(synchronizer, provider, factory, mediator, publisher, subscriber, disposer)
|
||||
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Add<ManageNavigationViewModel>();
|
||||
}
|
||||
|
||||
@@ -4,15 +4,14 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
[Notification(typeof(CreateEventArgs<ItemCategoryNavigationViewModel>), nameof(ItemCategoryCollectionViewModel))]
|
||||
public partial class ItemCategoryCollectionViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection<ItemCategoryNavigationViewModel>(synchronizer, provider, factory, mediator, publisher, subscriber, disposer)
|
||||
ObservableCollection<ItemCategoryNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private IContentTemplate template = template;
|
||||
|
||||
@@ -18,8 +18,7 @@ public partial class ItemCollectionViewModel :
|
||||
|
||||
private LockerViewModelConfiguration configuration;
|
||||
|
||||
public ItemCollectionViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
public ItemCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -28,7 +27,7 @@ public partial class ItemCollectionViewModel :
|
||||
IContentTemplate template,
|
||||
NamedComponent named,
|
||||
LockerViewModelConfiguration configuration,
|
||||
string? filter = null) : base(synchronizer, provider, factory, mediator, publisher, subscriber, disposer)
|
||||
string? filter = null) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
Named = $"{named}";
|
||||
@@ -71,6 +70,6 @@ public partial class ItemCollectionViewModel :
|
||||
return base.OnActivated();
|
||||
}
|
||||
|
||||
protected override AggregateExpression BuildAggregateExpression() =>
|
||||
new(Aggregate.As<ItemNavigationViewModel, LockerViewModelConfiguration>(configuration));
|
||||
protected override SynchronizeExpression BuildAggregateExpression() =>
|
||||
new(Synchronize.As<ItemNavigationViewModel, LockerViewModelConfiguration>(configuration));
|
||||
}
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ItemCommandHeaderViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
public partial class ItemCommandHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection(synchronizer, provider, factory, mediator, publisher, subscriber, disposer),
|
||||
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<NotifyEventArgs<ItemCommandHeaderCollection>>
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
namespace Bitvault;
|
||||
|
||||
[Notification(typeof(CreateEventArgs<ItemSectionViewModel>), nameof(ItemContentViewModel))]
|
||||
public partial class ItemContentViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
public partial class ItemContentViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory, IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
ItemState state = ItemState.Read) :
|
||||
ObservableCollection<ItemSectionViewModel>(synchronizer, provider, factory, mediator, publisher, subscriber, disposer),
|
||||
ObservableCollection<ItemSectionViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IItemEntryViewModel,
|
||||
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
|
||||
{
|
||||
@@ -23,7 +22,8 @@ public partial class ItemContentViewModel(ICollectionSynchronizer synchronizer,
|
||||
{
|
||||
if (category.Value is string value)
|
||||
{
|
||||
Fetch(() => new AggregateExpression(new AggerateEventArgs<IItemEntryViewModel, string>(value)), true);
|
||||
Fetch(() => new SynchronizeExpression(new SynchronizeEventArgs<IItemEntryViewModel,
|
||||
(string, ISynchronizationCollection<ItemSectionViewModel>)>((value, this))), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ public partial class ItemDropdownEntryViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
ICollectionSynchronization<IItemEntryViewModel> synchronization,
|
||||
ISynchronizationCollection<IItemEntryViewModel> synchronization,
|
||||
ItemEntryConfiguration configuration,
|
||||
string? key = default,
|
||||
string? value = default) : ItemEntryViewModel<string, string?>(provider, factory, mediator, publisher, subscriber, disposer, synchronization, configuration, key, value);
|
||||
@@ -2,16 +2,19 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ItemDropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<DropdownEntryConfiguration, IItemEntryViewModel?>
|
||||
public class ItemDropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<CreateEventArgs<DropdownEntryConfiguration>, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(DropdownEntryConfiguration args,
|
||||
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<DropdownEntryConfiguration> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemDropdownEntryViewModel>(args, args.Label, args.Value ?? "")
|
||||
is ItemDropdownEntryViewModel viewModel)
|
||||
if (args.Value is DropdownEntryConfiguration configuration)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
if (serviceFactory.Create<ItemDropdownEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
||||
is ItemDropdownEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(default);
|
||||
|
||||
@@ -2,13 +2,20 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IItemEntryConfiguration
|
||||
{
|
||||
string? Label { get; set; }
|
||||
|
||||
object? Value { get; set; }
|
||||
}
|
||||
|
||||
[JsonDerivedType(typeof(DropdownEntryConfiguration), typeDiscriminator: "Dropdown")]
|
||||
[JsonDerivedType(typeof(MaskedTextEntryConfiguration), typeDiscriminator: "MaskedText")]
|
||||
[JsonDerivedType(typeof(NoteEntryConfiguration), typeDiscriminator: "Note")]
|
||||
[JsonDerivedType(typeof(NumberEntryConfiguration), typeDiscriminator: "Number")]
|
||||
[JsonDerivedType(typeof(PasswordEntryConfiguration), typeDiscriminator: "Password")]
|
||||
[JsonDerivedType(typeof(TextEntryConfiguration), typeDiscriminator: "Text")]
|
||||
public record ItemEntryConfiguration
|
||||
public record ItemEntryConfiguration : IItemEntryConfiguration
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Label { get; set; }
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Toolkit.Foundation;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
@@ -9,7 +8,7 @@ public partial class ItemEntryViewModel<TKey, TValue>(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
ICollectionSynchronization<IItemEntryViewModel> synchronization,
|
||||
ISynchronizationCollection<IItemEntryViewModel> synchronization,
|
||||
ItemEntryConfiguration configuration,
|
||||
TKey? key = default,
|
||||
TValue? value = default) :
|
||||
@@ -21,9 +20,5 @@ public partial class ItemEntryViewModel<TKey, TValue>(IServiceProvider provider,
|
||||
public int Index => synchronization.IndexOf(this);
|
||||
|
||||
public Task<(int, ItemEntryConfiguration)> Handle(ConfirmEventArgs<ItemContentEntry> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var doo = Provider.GetRequiredService<ICollectionSynchronization<IItemEntryViewModel>>();
|
||||
return Task.FromResult((Index, configuration with { Value = Value }));
|
||||
}
|
||||
CancellationToken cancellationToken) => Task.FromResult((Index, configuration with { Value = Value }));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public partial class ItemMaskedTextEntryViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
ICollectionSynchronization<IItemEntryViewModel> synchronization,
|
||||
ISynchronizationCollection<IItemEntryViewModel> synchronization,
|
||||
ItemEntryConfiguration configuration,
|
||||
string? key = default,
|
||||
string? value = default) : ItemEntryViewModel<string, string?>(provider, factory, mediator, publisher, subscriber, disposer, synchronization, configuration, key, value);
|
||||
@@ -2,16 +2,19 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ItemMaskedTextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<MaskedTextEntryConfiguration, IItemEntryViewModel?>
|
||||
public class ItemMaskedTextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<CreateEventArgs<MaskedTextEntryConfiguration>, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(MaskedTextEntryConfiguration args,
|
||||
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<MaskedTextEntryConfiguration> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemMaskedTextEntryViewModel>(args, args.Label, args.Value ?? "") is
|
||||
ItemMaskedTextEntryViewModel viewModel)
|
||||
if (args.Value is MaskedTextEntryConfiguration configuration)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
if (serviceFactory.Create<ItemMaskedTextEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
||||
is ItemMaskedTextEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(default);
|
||||
|
||||
@@ -10,7 +10,6 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
ICollectionSynchronization<ItemNavigationViewModel> synchronization,
|
||||
NamedComponent named,
|
||||
Guid id,
|
||||
string name = "",
|
||||
@@ -26,7 +25,6 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
INotificationHandler<UnfavouriteEventArgs<Item>>,
|
||||
INotificationHandler<NotifyEventArgs<ItemHeader<string>>>,
|
||||
ISelectable,
|
||||
IIndexable,
|
||||
IRemovable
|
||||
{
|
||||
[ObservableProperty]
|
||||
@@ -53,8 +51,6 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
[ObservableProperty]
|
||||
private bool selected = selected;
|
||||
|
||||
public int Index => synchronization.IndexOf(this);
|
||||
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(ArchiveEventArgs<Item> args) =>
|
||||
|
||||
@@ -8,7 +8,7 @@ public partial class ItemPasswordEntryViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
ICollectionSynchronization<IItemEntryViewModel> synchronization,
|
||||
ISynchronizationCollection<IItemEntryViewModel> synchronization,
|
||||
ItemEntryConfiguration configuration,
|
||||
string? key = default,
|
||||
string? value = default) : ItemEntryViewModel<string, string?>(provider, factory, mediator, publisher, subscriber, disposer, synchronization, configuration, key, value);
|
||||
@@ -3,15 +3,18 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public class ItemPasswordEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<PasswordEntryConfiguration, IItemEntryViewModel?>
|
||||
IHandler<CreateEventArgs<PasswordEntryConfiguration>, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(PasswordEntryConfiguration args,
|
||||
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<PasswordEntryConfiguration> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemPasswordEntryViewModel>(args, args.Label, args.Value ?? "")
|
||||
is ItemPasswordEntryViewModel viewModel)
|
||||
if (args.Value is PasswordEntryConfiguration configuration)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
if (serviceFactory.Create<ItemPasswordEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
||||
is ItemPasswordEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(default);
|
||||
|
||||
@@ -4,18 +4,25 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
[Notification(typeof(CreateEventArgs<IItemEntryViewModel>), nameof(Section))]
|
||||
public partial class ItemSectionViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
public partial class ItemSectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
string section) : ObservableCollection<IItemEntryViewModel>(synchronizer, provider, factory, mediator, publisher, subscriber, disposer)
|
||||
ISynchronizationCollection<ItemSectionViewModel> synchronization,
|
||||
string section) : ObservableCollection<IItemEntryViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IHandler<ConfirmEventArgs<ItemSection>, (int, string)>,
|
||||
IIndexable
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string section = section;
|
||||
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public int Index => synchronization.IndexOf(this);
|
||||
|
||||
public Task<(int, string)> Handle(ConfirmEventArgs<ItemSection> args,
|
||||
CancellationToken cancellationToken) => Task.FromResult((0, Section));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public partial class ItemTextEntryViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
ICollectionSynchronization<IItemEntryViewModel> synchronization,
|
||||
ISynchronizationCollection<IItemEntryViewModel> synchronization,
|
||||
ItemEntryConfiguration configuration,
|
||||
string? key = default,
|
||||
string? value = default) : ItemEntryViewModel<string, string?>(provider, factory, mediator, publisher, subscriber, disposer, synchronization, configuration, key, value);
|
||||
@@ -3,15 +3,18 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public class ItemTextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<TextEntryConfiguration, IItemEntryViewModel?>
|
||||
IHandler<CreateEventArgs<TextEntryConfiguration>, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(TextEntryConfiguration args,
|
||||
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<TextEntryConfiguration> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemTextEntryViewModel>(args, args.Label, args.Value ?? "")
|
||||
is ItemTextEntryViewModel viewModel)
|
||||
if (args.Value is TextEntryConfiguration configuration)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
if (serviceFactory.Create<ItemTextEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
||||
is ItemTextEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(default);
|
||||
|
||||
@@ -29,8 +29,7 @@ public partial class ItemViewModel :
|
||||
[ObservableProperty]
|
||||
private bool fromCategory;
|
||||
|
||||
public ItemViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
public ItemViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -42,7 +41,7 @@ public partial class ItemViewModel :
|
||||
bool fromCategory = false,
|
||||
string name = "",
|
||||
bool favourite = false,
|
||||
bool archived = false) : base(synchronizer,provider, factory, mediator, publisher, subscriber, disposer)
|
||||
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
Named = $"{named}";
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class LockerHeaderViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
public partial class LockerHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection(synchronizer, provider, factory, mediator, publisher, subscriber, disposer),
|
||||
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<NotifyEventArgs<LockerCommandHeaderCollection>>
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
@@ -27,8 +27,7 @@ public partial class LockerNavigationViewModel :
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
public LockerNavigationViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
public LockerNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -36,7 +35,7 @@ public partial class LockerNavigationViewModel :
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
string name,
|
||||
bool selected) : base(synchronizer,provider, factory, mediator, publisher, subscriber, disposer)
|
||||
bool selected) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
Name = name;
|
||||
|
||||
@@ -11,15 +11,14 @@ public partial class MainViewModel :
|
||||
[ObservableProperty]
|
||||
private FooterViewModel footer;
|
||||
|
||||
public MainViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
public MainViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
FooterViewModel footer) : base(synchronizer, provider, factory, mediator, publisher, subscriber, disposer)
|
||||
FooterViewModel footer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
Footer = footer;
|
||||
|
||||
@@ -6,14 +6,13 @@ public partial class ManageViewModel :
|
||||
ObservableCollection,
|
||||
IMainNavigationViewModel
|
||||
{
|
||||
public ManageViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
public ManageViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) : base(synchronizer,provider, factory, mediator, publisher, subscriber, disposer)
|
||||
IContentTemplate template) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
|
||||
|
||||
+3
-3
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggregateItemCategoryViewModelHandler(IItemConfigurationCollection configurations,
|
||||
public class SynchronizeItemCategoryViewModelHandler(IItemConfigurationCollection configurations,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<ItemCategoryNavigationViewModel>>
|
||||
INotificationHandler<SynchronizeEventArgs<ItemCategoryNavigationViewModel>>
|
||||
{
|
||||
public Task Handle(AggerateEventArgs<ItemCategoryNavigationViewModel> args)
|
||||
public Task Handle(SynchronizeEventArgs<ItemCategoryNavigationViewModel> args)
|
||||
{
|
||||
bool selected = true;
|
||||
foreach (KeyValuePair<string, Func<ItemConfiguration>> configuration in configurations)
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Reflection;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class SynchronizeItemContentFromCategoryViewModelHandler(IItemConfigurationCollection configurations,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<SynchronizeEventArgs<IItemEntryViewModel,
|
||||
(string, ISynchronizationCollection<ItemSectionViewModel>)>>
|
||||
{
|
||||
public async Task Handle(SynchronizeEventArgs<IItemEntryViewModel, (string, ISynchronizationCollection<ItemSectionViewModel>)> args)
|
||||
{
|
||||
(string category, ISynchronizationCollection<ItemSectionViewModel> synchronization) = args.Value;
|
||||
if (configurations.TryGetValue(category, out Func<ItemConfiguration>? factory))
|
||||
{
|
||||
if (factory.Invoke() is ItemConfiguration configuration)
|
||||
{
|
||||
foreach (ItemSectionConfiguration configurationSection in configuration.Sections)
|
||||
{
|
||||
string section = $"{nameof(ItemSection)}:{Guid.NewGuid()}";
|
||||
if (serviceFactory.Create<ItemSectionViewModel>(synchronization, section)
|
||||
is ItemSectionViewModel sectionViewModel)
|
||||
{
|
||||
publisher.Publish(Create.As(sectionViewModel), nameof(ItemContentViewModel));
|
||||
foreach (IItemEntryConfiguration entryConfiguration in configurationSection.Entries)
|
||||
{
|
||||
Type messageType = typeof(CreateEventArgs<>).MakeGenericType(entryConfiguration.GetType());
|
||||
ConstructorInfo? constructor = messageType.GetConstructor([entryConfiguration.GetType(), typeof(object[])]);
|
||||
|
||||
if (constructor?.Invoke(new object[] { entryConfiguration, new object[] { sectionViewModel } }) is object message)
|
||||
{
|
||||
if (await mediator.Handle<object, IItemEntryViewModel?>(message, entryConfiguration.GetType().Name) is IItemEntryViewModel entryViewModel)
|
||||
{
|
||||
publisher.Publish(Create.As(entryViewModel), section);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggregateItemContentViewModelHandler(IMediator mediator,
|
||||
public class SynchronizeItemContentViewModelHandler(IMediator mediator,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<IItemEntryViewModel>>
|
||||
INotificationHandler<SynchronizeEventArgs<IItemEntryViewModel>>
|
||||
{
|
||||
public Task Handle(AggerateEventArgs<IItemEntryViewModel> args)
|
||||
public Task Handle(SynchronizeEventArgs<IItemEntryViewModel> args)
|
||||
{
|
||||
//wModel>(false) is ItemHeaderViewModel viewModel)
|
||||
//{
|
||||
+4
-6
@@ -3,15 +3,13 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateItemViewModelHandler(IMediator mediator,
|
||||
public class SynchronizeItemViewModelHandler(IMediator mediator,
|
||||
IServiceProvider serviceProvider,
|
||||
ICache<Item<(Guid, string)>> cache,
|
||||
IPublisher publisher,
|
||||
LockerViewModelConfiguration dd) :
|
||||
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel,
|
||||
LockerViewModelConfiguration>>
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<SynchronizeEventArgs<ItemNavigationViewModel, LockerViewModelConfiguration>>
|
||||
{
|
||||
public async Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
||||
public async Task Handle(SynchronizeEventArgs<ItemNavigationViewModel,
|
||||
LockerViewModelConfiguration> args)
|
||||
{
|
||||
if (args.Value is LockerViewModelConfiguration configuration)
|
||||
+7
-5
@@ -3,21 +3,23 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggregateMainViewModelHandler(IPublisher publisher,
|
||||
public class SynchronizeMainViewModelHandler(IPublisher publisher,
|
||||
ILockerHostCollection lockers) :
|
||||
INotificationHandler<AggerateEventArgs<IMainNavigationViewModel>>
|
||||
INotificationHandler<SynchronizeEventArgs<IMainNavigationViewModel>>
|
||||
{
|
||||
public Task Handle(AggerateEventArgs<IMainNavigationViewModel> args)
|
||||
public Task Handle(SynchronizeEventArgs<IMainNavigationViewModel> args)
|
||||
{
|
||||
bool selected = true;
|
||||
foreach (IComponentHost locker in lockers.OrderBy(x => x.Services.GetRequiredService<IConfigurationDescriptor<LockerConfiguration>>()
|
||||
is IConfigurationDescriptor<LockerConfiguration> descriptor ? descriptor.Name : null))
|
||||
{
|
||||
if (locker.Services.GetRequiredService<IConfigurationDescriptor<LockerConfiguration>>() is IConfigurationDescriptor<LockerConfiguration> descriptor)
|
||||
if (locker.Services.GetRequiredService<IConfigurationDescriptor<LockerConfiguration>>()
|
||||
is IConfigurationDescriptor<LockerConfiguration> descriptor)
|
||||
{
|
||||
if (locker.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||
{
|
||||
if (factory.Create<LockerNavigationViewModel>(descriptor.Name, selected) is LockerNavigationViewModel viewModel)
|
||||
if (factory.Create<LockerNavigationViewModel>(descriptor.Name, selected)
|
||||
is LockerNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(Create.As<IMainNavigationViewModel>(viewModel),
|
||||
nameof(MainViewModel));
|
||||
Reference in New Issue
Block a user