Added ICollectionSynchronization
This commit is contained in:
@@ -79,13 +79,13 @@ public partial class App : Application
|
||||
return new ItemConfigurationCollection(items.ToDictionary(x => x.Name, x => (Func<ItemConfiguration>)(() => x.Value)));
|
||||
});
|
||||
|
||||
services.TryAddSingleton<IValueStore<SecurityKey>, ValueStore<SecurityKey>>();
|
||||
services.TryAddSingleton<IValueStore<LockerConnection>, ValueStore<LockerConnection>>();
|
||||
services.TryAddSingleton<IDecoratorService<SecurityKey>, DecoratorService<SecurityKey>>();
|
||||
services.TryAddSingleton<IDecoratorService<LockerConnection>, DecoratorService<LockerConnection>>();
|
||||
|
||||
services.AddDbContextFactory<LockerContext>((provider, args) =>
|
||||
{
|
||||
if (provider.GetRequiredService<IValueStore<LockerConnection>>()
|
||||
is IValueStore<LockerConnection> connection)
|
||||
if (provider.GetRequiredService<IDecoratorService<LockerConnection>>()
|
||||
is IDecoratorService<LockerConnection> connection)
|
||||
{
|
||||
args.UseSqlite($"{connection.Value}");
|
||||
}
|
||||
@@ -111,6 +111,11 @@ public partial class App : Application
|
||||
services.AddTemplate<LockerViewModel, LockerView>("Locker");
|
||||
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
||||
|
||||
services.AddSingleton<IDecoratorService<ICollectionSynchronization<ItemNavigationViewModel>>,
|
||||
DecoratorService<ICollectionSynchronization<ItemNavigationViewModel>>>();
|
||||
|
||||
services.AddSingleton(provider => provider.GetRequiredService<IDecoratorService<ICollectionSynchronization<ItemNavigationViewModel>>>().Value!);
|
||||
|
||||
services.AddHandler<AggerateItemViewModelHandler>();
|
||||
|
||||
services.AddTemplate<LockerHeaderViewModel, LockerHeaderView>("LockerHeader");
|
||||
@@ -123,7 +128,7 @@ public partial class App : Application
|
||||
|
||||
services.AddHandler<AggregateItemCategoryViewModelHandler>();
|
||||
|
||||
services.AddScoped<IValueStore<Item<(Guid, string)>>, ValueStore<Item<(Guid, string)>>>();
|
||||
services.AddScoped<IDecoratorService<Item<(Guid, string)>>, DecoratorService<Item<(Guid, string)>>>();
|
||||
|
||||
services.AddTemplate<AddItemNavigationViewModel, AddItemNavigationView>();
|
||||
|
||||
@@ -143,6 +148,12 @@ public partial class App : Application
|
||||
services.AddTemplate<ItemMaskedTextEntryViewModel, ItemMaskedTextEntryView>();
|
||||
services.AddTemplate<ItemDropdownEntryViewModel, ItemDropdownEntryView>();
|
||||
|
||||
services.AddScoped<IDecoratorService<ICollectionSynchronization<IItemEntryViewModel>>,
|
||||
DecoratorService<ICollectionSynchronization<IItemEntryViewModel>>>();
|
||||
|
||||
services.AddScoped(provider => provider.GetRequiredService<IDecoratorService<ICollectionSynchronization<IItemEntryViewModel>>>().Value!);
|
||||
|
||||
|
||||
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
|
||||
|
||||
services.AddTemplate<FavouriteItemActionViewModel, FavouriteItemActionView>();
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
x:DataType="vm:ItemMaskedTextEntryViewModel"
|
||||
Header="{Binding Key}">
|
||||
<SettingsExpander.Footer>
|
||||
<TextBox MinWidth="264" />
|
||||
<TextBox MinWidth="264" Text="{Binding Value}" />
|
||||
</SettingsExpander.Footer>
|
||||
</SettingsExpander>
|
||||
@@ -9,6 +9,7 @@
|
||||
<TextBox
|
||||
MinWidth="264"
|
||||
Classes="revealPasswordButton"
|
||||
PasswordChar="●" />
|
||||
PasswordChar="●"
|
||||
Text="{Binding Value}" />
|
||||
</SettingsExpander.Footer>
|
||||
</SettingsExpander>
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
x:DataType="vm:ItemTextEntryViewModel"
|
||||
Header="{Binding Key}">
|
||||
<SettingsExpander.Footer>
|
||||
<TextBox MinWidth="264" />
|
||||
<TextBox MinWidth="264" Text="{Binding Value}" />
|
||||
</SettingsExpander.Footer>
|
||||
</SettingsExpander>
|
||||
|
||||
@@ -8,8 +8,10 @@ public record BlobEntry
|
||||
{
|
||||
public byte[]? Data { get; set; }
|
||||
|
||||
public DocumentType Type { get; set; }
|
||||
public int Type { get; set; }
|
||||
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public DateTimeOffset DateTime { get; set; }
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Bitvault.Data;
|
||||
|
||||
public enum DocumentType
|
||||
{
|
||||
Form,
|
||||
File
|
||||
}
|
||||
@@ -16,19 +16,19 @@ public class AggregateItemContentFromCategoryViewModelHandler(IItemConfiguration
|
||||
{
|
||||
if (factory.Invoke() is ItemConfiguration configuration)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
foreach (ItemSectionConfiguration section in configuration.Sections)
|
||||
foreach (ItemSectionConfiguration configurationSection in configuration.Sections)
|
||||
{
|
||||
if (serviceFactory.Create<ItemSectionViewModel>($"{nameof(ItemSection)}{index}") is ItemSectionViewModel sectionViewModel)
|
||||
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 section.Entries)
|
||||
foreach (ItemEntryConfiguration entryConfiguration in configurationSection.Entries)
|
||||
{
|
||||
if (await mediator.Handle<ItemEntryConfiguration, IItemEntryViewModel?>(entryConfiguration,
|
||||
entryConfiguration.GetType().Name) is IItemEntryViewModel entryViewModel)
|
||||
{
|
||||
publisher.Publish(Create.As(entryViewModel), $"{nameof(ItemSection)}{index}");
|
||||
publisher.Publish(Create.As(entryViewModel), section);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ public class AggerateItemViewModelHandler(IMediator mediator,
|
||||
{
|
||||
IServiceScope serviceScope = serviceProvider.CreateScope();
|
||||
IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService<IServiceFactory>();
|
||||
IValueStore<Item<(Guid, string)>> valueStore = serviceScope.ServiceProvider.GetRequiredService<IValueStore<Item<(Guid, string)>>>();
|
||||
IDecoratorService<Item<(Guid, string)>> decoratorService = serviceScope.ServiceProvider.GetRequiredService<IDecoratorService<Item<(Guid, string)>>>();
|
||||
|
||||
if (serviceFactory.Create<ItemNavigationViewModel>(Id, Name, "Description", Category, selected, Favourite, Archived) is ItemNavigationViewModel viewModel)
|
||||
{
|
||||
Item<(Guid, string)> item = new((Id, Name));
|
||||
|
||||
valueStore.Set(item);
|
||||
decoratorService.Set(item);
|
||||
|
||||
cache.Add(item);
|
||||
publisher.Publish(Create.As(viewModel), nameof(ItemCollectionViewModel));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ArchiveItemHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
public class ArchiveItemHandler(IDecoratorService<Item<(Guid, string)>> decoratorService,
|
||||
ICache<Item<(Guid, string)>> cache,
|
||||
IMediator mediator) :
|
||||
INotificationHandler<ArchiveEventArgs<Item>>
|
||||
@@ -11,7 +11,7 @@ public class ArchiveItemHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
{
|
||||
try
|
||||
{
|
||||
if (valueStore.Value is Item<(Guid, string)> item)
|
||||
if (decoratorService.Value is Item<(Guid, string)> item)
|
||||
{
|
||||
if (cache.Contains(item))
|
||||
{
|
||||
|
||||
@@ -8,11 +8,14 @@ public class ConfirmCreateItemHandler(IMediator mediator,
|
||||
{
|
||||
public async Task Handle(ConfirmEventArgs<Item> args)
|
||||
{
|
||||
string? name = await mediator.Handle<ConfirmEventArgs<Item>,
|
||||
string?>(args, nameof(ItemHeader));
|
||||
string? name = await mediator.Handle<ConfirmEventArgs<ItemHeader>,
|
||||
string>(Confirm.As<ItemHeader>());
|
||||
|
||||
if (name is not null)
|
||||
{
|
||||
IList<ItemEntryConfiguration?> entries = await mediator.HandleMany<ConfirmEventArgs<ItemContentEntry>,
|
||||
ItemEntryConfiguration>(Confirm.As<ItemContentEntry>());
|
||||
|
||||
Guid id = Guid.NewGuid();
|
||||
publisher.Publish(Created.As(new Item<(Guid, string)>((id, name))));
|
||||
|
||||
|
||||
@@ -2,24 +2,24 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ConfirmUpdateItemHandler(IValueStore<Item<(Guid, string)>> store,
|
||||
public class ConfirmUpdateItemHandler(IDecoratorService<Item<(Guid, string)>> store,
|
||||
IMediator mediator,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ConfirmEventArgs<Item>>
|
||||
{
|
||||
public async Task Handle(ConfirmEventArgs<Item> args)
|
||||
{
|
||||
ItemHeaderConfiguration? configuration = await mediator.Handle<ConfirmEventArgs<Item>,
|
||||
ItemHeaderConfiguration>(args);
|
||||
string? name = await mediator.Handle<ConfirmEventArgs<ItemHeader>,
|
||||
string>(Confirm.As<ItemHeader>());
|
||||
|
||||
if (configuration is not null)
|
||||
if (name is not null)
|
||||
{
|
||||
publisher.Publish(Notify.As(configuration));
|
||||
|
||||
|
||||
publisher.Publish(Notify.As(new ItemHeader<string>(name)));
|
||||
if (store?.Value is Item<(Guid, string)> item)
|
||||
{
|
||||
(Guid id, string _) = item.Value;
|
||||
string? name = configuration.Name;
|
||||
|
||||
Item<(Guid, string)> newItem = new((id, name));
|
||||
publisher.Publish(Modified.As(item, newItem));
|
||||
|
||||
@@ -22,6 +22,7 @@ public class CreateItemHandler(IDbContextFactory<LockerContext> dbContextFactory
|
||||
{
|
||||
result = await context.AddAsync(new ItemEntry { Id = id, Name = name, Category = category }, cancellationToken);
|
||||
await context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
}, cancellationToken);
|
||||
|
||||
if (result is not null)
|
||||
|
||||
@@ -18,7 +18,7 @@ public class CreateLockerHandler(ILockerFactory componentFactory,
|
||||
if (componentFactory.Create(name) is IComponentHost host)
|
||||
{
|
||||
ISecurityKeyFactory keyVaultFactory = host.Services.GetRequiredService<ISecurityKeyFactory>();
|
||||
IValueStore<SecurityKey> secureKeyStore = host.Services.GetRequiredService<IValueStore<SecurityKey>>();
|
||||
IDecoratorService<SecurityKey> secureKeyStore = host.Services.GetRequiredService<IDecoratorService<SecurityKey>>();
|
||||
ILockerStorageFactory lockerStorageFactory = host.Services.GetRequiredService<ILockerStorageFactory>();
|
||||
|
||||
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password)) is SecurityKey key)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class FavouriteItemHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
public class FavouriteItemHandler(IDecoratorService<Item<(Guid, string)>> decoratorService,
|
||||
IMediator mediator) :
|
||||
INotificationHandler<FavouriteEventArgs<Item>>
|
||||
{
|
||||
@@ -10,7 +10,7 @@ public class FavouriteItemHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
{
|
||||
try
|
||||
{
|
||||
if (valueStore.Value is Item<(Guid, string)> item)
|
||||
if (decoratorService.Value is Item<(Guid, string)> item)
|
||||
{
|
||||
(Guid id, string name) = item.Value;
|
||||
await mediator.Handle<UpdateEventArgs<(Guid, int)>, bool>(new UpdateEventArgs<(Guid, int)>((id, 1)));
|
||||
|
||||
@@ -5,12 +5,13 @@ namespace Bitvault;
|
||||
public partial class FooterViewModel :
|
||||
ObservableCollection<IMainNavigationViewModel>
|
||||
{
|
||||
public FooterViewModel(IServiceProvider provider,
|
||||
public FooterViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
IDisposer disposer) : base(synchronizer, provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Add<ManageNavigationViewModel>();
|
||||
}
|
||||
|
||||
@@ -4,14 +4,15 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
[Notification(typeof(CreateEventArgs<ItemCategoryNavigationViewModel>), nameof(ItemCategoryCollectionViewModel))]
|
||||
public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
||||
public partial class ItemCategoryCollectionViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection<ItemCategoryNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
ObservableCollection<ItemCategoryNavigationViewModel>(synchronizer, provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private IContentTemplate template = template;
|
||||
|
||||
@@ -18,7 +18,8 @@ public partial class ItemCollectionViewModel :
|
||||
|
||||
private LockerViewModelConfiguration configuration;
|
||||
|
||||
public ItemCollectionViewModel(IServiceProvider provider,
|
||||
public ItemCollectionViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -27,7 +28,7 @@ public partial class ItemCollectionViewModel :
|
||||
IContentTemplate template,
|
||||
NamedComponent named,
|
||||
LockerViewModelConfiguration configuration,
|
||||
string? filter = null) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
string? filter = null) : base(synchronizer, provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
Named = $"{named}";
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ItemCommandHeaderViewModel(IServiceProvider provider,
|
||||
public partial class ItemCommandHeaderViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
ObservableCollection(synchronizer, provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<NotifyEventArgs<ItemCommandHeaderCollection>>
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record ItemContentEntry<TValue>(TValue Value);
|
||||
|
||||
public record ItemContentEntry;
|
||||
@@ -3,14 +3,15 @@
|
||||
namespace Bitvault;
|
||||
|
||||
[Notification(typeof(CreateEventArgs<ItemSectionViewModel>), nameof(ItemContentViewModel))]
|
||||
public partial class ItemContentViewModel(IServiceProvider provider,
|
||||
public partial class ItemContentViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
IServiceFactory factory, IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
ItemState state = ItemState.Read) :
|
||||
ObservableCollection<ItemSectionViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
ObservableCollection<ItemSectionViewModel>(synchronizer, provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IItemEntryViewModel,
|
||||
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ItemCreatedHandler(IServiceProvider serviceProvider,
|
||||
|
||||
IServiceScope serviceScope = serviceProvider.CreateScope();
|
||||
IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService<IServiceFactory>();
|
||||
IValueStore<Item<(Guid, string)>> valueStore = serviceScope.ServiceProvider.GetRequiredService<IValueStore<Item<(Guid, string)>>>();
|
||||
IDecoratorService<Item<(Guid, string)>> decoratorService = serviceScope.ServiceProvider.GetRequiredService<IDecoratorService<Item<(Guid, string)>>>();
|
||||
|
||||
if (serviceFactory.Create<ItemNavigationViewModel>(id, name, "Description", true)
|
||||
is ItemNavigationViewModel viewModel)
|
||||
@@ -24,7 +24,7 @@ public class ItemCreatedHandler(IServiceProvider serviceProvider,
|
||||
cache.Add(item);
|
||||
|
||||
int index = cache.IndexOf(item);
|
||||
valueStore.Set(item);
|
||||
decoratorService.Set(item);
|
||||
|
||||
publisher.Publish(Insert.As(index, viewModel),
|
||||
nameof(ItemCollectionViewModel));
|
||||
|
||||
@@ -8,6 +8,7 @@ public partial class ItemDropdownEntryViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
ICollectionSynchronization<IItemEntryViewModel> synchronization,
|
||||
ItemEntryConfiguration configuration,
|
||||
string? key = default,
|
||||
object? value = default) : Observable<string, object?>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||
IItemEntryViewModel;
|
||||
string? value = default) : ItemEntryViewModel<string, string?>(provider, factory, mediator, publisher, subscriber, disposer, synchronization, configuration, key, value);
|
||||
@@ -8,7 +8,8 @@ public class ItemDropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
public Task<IItemEntryViewModel?> Handle(DropdownEntryConfiguration args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemDropdownEntryViewModel>(args.Label, args.Value ?? new object()) is ItemDropdownEntryViewModel viewModel)
|
||||
if (serviceFactory.Create<ItemDropdownEntryViewModel>(args, args.Label, args.Value ?? "")
|
||||
is ItemDropdownEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Toolkit.Foundation;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ItemEntryViewModel<TKey, TValue> :
|
||||
Observable<TKey, TValue>
|
||||
public partial class ItemEntryViewModel<TKey, TValue>(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
ICollectionSynchronization<IItemEntryViewModel> synchronization,
|
||||
ItemEntryConfiguration configuration,
|
||||
TKey? key = default,
|
||||
TValue? value = default) :
|
||||
Observable<TKey, TValue>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||
IHandler<ConfirmEventArgs<ItemContentEntry>, ItemEntryConfiguration>,
|
||||
IItemEntryViewModel,
|
||||
IIndexable
|
||||
{
|
||||
public ItemEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string type,
|
||||
TKey? key = default,
|
||||
TValue? value = default) : base(provider, factory, mediator, publisher, subscriber, disposer, key, value)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
public int Index => synchronization.IndexOf(this);
|
||||
|
||||
[ObservableProperty]
|
||||
private string type;
|
||||
public Task<ItemEntryConfiguration> Handle(ConfirmEventArgs<ItemContentEntry> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(configuration with { Value = Value });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record ItemHeader<TValue>(TValue Value);
|
||||
|
||||
public record ItemHeader;
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record ItemHeaderConfiguration
|
||||
{
|
||||
public string Name { get; init; } = "";
|
||||
}
|
||||
@@ -3,14 +3,13 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Notification(typeof(ConfirmEventArgs<Item>), nameof(ItemHeader))]
|
||||
public partial class ItemHeaderViewModel :
|
||||
Observable<string, string>,
|
||||
IHandler<ValidationEventArgs<Item>, bool>,
|
||||
IHandler<ConfirmEventArgs<Item>, string?>,
|
||||
INotificationHandler<UpdateEventArgs<Item>>,
|
||||
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||
INotificationHandler<CancelEventArgs<Item>>,
|
||||
IHandler<ValidationEventArgs<ItemHeader>, bool>,
|
||||
IHandler<ConfirmEventArgs<ItemHeader>, string?>,
|
||||
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
@@ -34,7 +33,7 @@ public partial class ItemHeaderViewModel :
|
||||
Track(nameof(Value), () => Value, newValue => Value = newValue);
|
||||
}
|
||||
|
||||
public Task<bool> Handle(ValidationEventArgs<Item> args,
|
||||
public Task<bool> Handle(ValidationEventArgs<ItemHeader> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(true);
|
||||
@@ -69,6 +68,6 @@ public partial class ItemHeaderViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task<string?> Handle(ConfirmEventArgs<Item> args,
|
||||
public Task<string?> Handle(ConfirmEventArgs<ItemHeader> args,
|
||||
CancellationToken cancellationToken) => Task.FromResult(Value);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ public partial class ItemMaskedTextEntryViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
ICollectionSynchronization<IItemEntryViewModel> synchronization,
|
||||
ItemEntryConfiguration configuration,
|
||||
string? key = default,
|
||||
object? value = default) : Observable<string, object?>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||
IItemEntryViewModel;
|
||||
string? value = default) : ItemEntryViewModel<string, string?>(provider, factory, mediator, publisher, subscriber, disposer, synchronization, configuration, key, value);
|
||||
@@ -8,7 +8,7 @@ public class ItemMaskedTextEntryViewModelHandler(IServiceFactory serviceFactory)
|
||||
public Task<IItemEntryViewModel?> Handle(MaskedTextEntryConfiguration args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemMaskedTextEntryViewModel>(args.Label, args.Value ?? new object()) is
|
||||
if (serviceFactory.Create<ItemMaskedTextEntryViewModel>(args, args.Label, args.Value ?? "") is
|
||||
ItemMaskedTextEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ItemModifiedHandler(IServiceProvider serviceProvider,
|
||||
if (cachedItem is not null)
|
||||
{
|
||||
IServiceScope serviceScope = serviceProvider.CreateScope();
|
||||
IValueStore<Item<(Guid, string)>> valueStore = serviceScope.ServiceProvider.GetRequiredService<IValueStore<Item<(Guid, string)>>>();
|
||||
IDecoratorService<Item<(Guid, string)>> decoratorService = serviceScope.ServiceProvider.GetRequiredService<IDecoratorService<Item<(Guid, string)>>>();
|
||||
|
||||
int oldIndex = cache.IndexOf(cachedItem);
|
||||
cache.Remove(cachedItem);
|
||||
@@ -26,7 +26,7 @@ public class ItemModifiedHandler(IServiceProvider serviceProvider,
|
||||
cache.Add(newItem);
|
||||
|
||||
int newIndex = cache.IndexOf(newItem);
|
||||
valueStore.Set(newItem);
|
||||
decoratorService.Set(newItem);
|
||||
|
||||
publisher.Publish(MoveTo.As<ItemNavigationViewModel>(oldIndex, newIndex),
|
||||
nameof(ItemCollectionViewModel));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Toolkit.Foundation;
|
||||
using Toolkit.UI.Avalonia;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
@@ -11,6 +10,7 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
ICollectionSynchronization<ItemNavigationViewModel> synchronization,
|
||||
NamedComponent named,
|
||||
Guid id,
|
||||
string name = "",
|
||||
@@ -24,8 +24,9 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
INotificationHandler<UnarchiveEventArgs<Item>>,
|
||||
INotificationHandler<FavouriteEventArgs<Item>>,
|
||||
INotificationHandler<UnfavouriteEventArgs<Item>>,
|
||||
INotificationHandler<NotifyEventArgs<ItemHeaderConfiguration>>,
|
||||
INotificationHandler<NotifyEventArgs<ItemHeader<string>>>,
|
||||
ISelectable,
|
||||
IIndexable,
|
||||
IRemovable
|
||||
{
|
||||
[ObservableProperty]
|
||||
@@ -52,7 +53,8 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
[ObservableProperty]
|
||||
private bool selected = selected;
|
||||
|
||||
public bool Attached { get; set; }
|
||||
public int Index => synchronization.IndexOf(this);
|
||||
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(ArchiveEventArgs<Item> args) =>
|
||||
@@ -67,11 +69,11 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
public Task Handle(UnfavouriteEventArgs<Item> args) =>
|
||||
Task.FromResult(Favourite = false);
|
||||
|
||||
public Task Handle(NotifyEventArgs<ItemHeaderConfiguration> args)
|
||||
public Task Handle(NotifyEventArgs<ItemHeader<string>> args)
|
||||
{
|
||||
if (args.Value is ItemHeaderConfiguration configuration)
|
||||
if (args.Value is ItemHeader<string> header)
|
||||
{
|
||||
Name = configuration.Name;
|
||||
Name = header.Value;
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -8,7 +8,7 @@ public partial class ItemPasswordEntryViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string type,
|
||||
ICollectionSynchronization<IItemEntryViewModel> synchronization,
|
||||
ItemEntryConfiguration configuration,
|
||||
string? key = default,
|
||||
object? value = default) : ItemEntryViewModel<string, object?>(provider, factory, mediator, publisher, subscriber, disposer, type, key, value),
|
||||
IItemEntryViewModel;
|
||||
string? value = default) : ItemEntryViewModel<string, string?>(provider, factory, mediator, publisher, subscriber, disposer, synchronization, configuration, key, value);
|
||||
@@ -8,7 +8,7 @@ public class ItemPasswordEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
public Task<IItemEntryViewModel?> Handle(PasswordEntryConfiguration args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemPasswordEntryViewModel>("Password", args.Label, args.Value ?? new object())
|
||||
if (serviceFactory.Create<ItemPasswordEntryViewModel>(args, args.Label, args.Value ?? "")
|
||||
is ItemPasswordEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
|
||||
@@ -4,14 +4,15 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
[Notification(typeof(CreateEventArgs<IItemEntryViewModel>), nameof(Section))]
|
||||
public partial class ItemSectionViewModel(IServiceProvider provider,
|
||||
public partial class ItemSectionViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
string section) : ObservableCollection<IItemEntryViewModel>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
string section) : ObservableCollection<IItemEntryViewModel>(synchronizer, provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string section = section;
|
||||
|
||||
@@ -8,6 +8,7 @@ public partial class ItemTextEntryViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
ICollectionSynchronization<IItemEntryViewModel> synchronization,
|
||||
ItemEntryConfiguration configuration,
|
||||
string? key = default,
|
||||
string? value = default) : Observable<string, string>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||
IItemEntryViewModel;
|
||||
string? value = default) : ItemEntryViewModel<string, string?>(provider, factory, mediator, publisher, subscriber, disposer, synchronization, configuration, key, value);
|
||||
@@ -8,7 +8,8 @@ public class ItemTextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
public Task<IItemEntryViewModel?> Handle(TextEntryConfiguration args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemTextEntryViewModel>(args.Label, args.Value ?? "") is ItemTextEntryViewModel viewModel)
|
||||
if (serviceFactory.Create<ItemTextEntryViewModel>(args, args.Label, args.Value ?? "")
|
||||
is ItemTextEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ public partial class ItemViewModel :
|
||||
[ObservableProperty]
|
||||
private bool fromCategory;
|
||||
|
||||
public ItemViewModel(IServiceProvider provider,
|
||||
public ItemViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -41,7 +42,7 @@ public partial class ItemViewModel :
|
||||
bool fromCategory = false,
|
||||
string name = "",
|
||||
bool favourite = false,
|
||||
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
bool archived = false) : base(synchronizer,provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
Named = $"{named}";
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class LockerHeaderViewModel(IServiceProvider provider,
|
||||
public partial class LockerHeaderViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
ObservableCollection(synchronizer, provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<NotifyEventArgs<LockerCommandHeaderCollection>>
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
@@ -27,7 +27,8 @@ public partial class LockerNavigationViewModel :
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
public LockerNavigationViewModel(IServiceProvider provider,
|
||||
public LockerNavigationViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -35,7 +36,7 @@ public partial class LockerNavigationViewModel :
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
string name,
|
||||
bool selected) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
bool selected) : base(synchronizer,provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
Name = name;
|
||||
|
||||
@@ -6,7 +6,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerStorageFactory(IValueStore<LockerConnection> connection,
|
||||
public class LockerStorageFactory(IDecoratorService<LockerConnection> connection,
|
||||
IHostEnvironment environment,
|
||||
IServiceProvider provider) :
|
||||
ILockerStorageFactory
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
@@ -10,14 +11,15 @@ public partial class MainViewModel :
|
||||
[ObservableProperty]
|
||||
private FooterViewModel footer;
|
||||
|
||||
public MainViewModel(IServiceProvider provider,
|
||||
public MainViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
FooterViewModel footer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
FooterViewModel footer) : base(synchronizer, provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
Footer = footer;
|
||||
|
||||
@@ -6,13 +6,14 @@ public partial class ManageViewModel :
|
||||
ObservableCollection,
|
||||
IMainNavigationViewModel
|
||||
{
|
||||
public ManageViewModel(IServiceProvider provider,
|
||||
public ManageViewModel(ICollectionSynchronizer synchronizer,
|
||||
IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
IContentTemplate template) : base(synchronizer,provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class UnarchiveItemHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
public class UnarchiveItemHandler(IDecoratorService<Item<(Guid, string)>> decoratorService,
|
||||
IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
INotificationHandler<UnarchiveEventArgs<Item>>
|
||||
{
|
||||
@@ -12,7 +12,7 @@ public class UnarchiveItemHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
{
|
||||
try
|
||||
{
|
||||
if (valueStore.Value is Item<(Guid, string)> item)
|
||||
if (decoratorService.Value is Item<(Guid, string)> item)
|
||||
{
|
||||
(Guid id, string name) = item.Value;
|
||||
await Task.Run(async () =>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
public class UnfavouriteItemHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
public class UnfavouriteItemHandler(IDecoratorService<Item<(Guid, string)>> decoratorService,
|
||||
IMediator mediator) :
|
||||
INotificationHandler<UnfavouriteEventArgs<Item>>
|
||||
{
|
||||
@@ -9,7 +9,7 @@ public class UnfavouriteItemHandler(IValueStore<Item<(Guid, string)>> valueStore
|
||||
{
|
||||
try
|
||||
{
|
||||
if (valueStore.Value is Item<(Guid, string)> item)
|
||||
if (decoratorService.Value is Item<(Guid, string)> item)
|
||||
{
|
||||
(Guid id, string name) = item.Value;
|
||||
await mediator.Handle<UpdateEventArgs<(Guid, int)>, bool>(new UpdateEventArgs<(Guid, int)>((id, 0)));
|
||||
|
||||
Reference in New Issue
Block a user