Mass rename to align planned codename
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateContainerCategoryViewModelHandler(IProxyService<IEnumerable<ItemConfiguration>> proxyConfigurations,
|
||||
public class AggerateLockerCategoryViewModelHandler(IProxyService<IEnumerable<ItemConfiguration>> proxyConfigurations,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<ItemCategoryNavigationViewModel>>
|
||||
+6
-6
@@ -3,23 +3,23 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateContainerItemViewModelHandler(IMediator mediator,
|
||||
public class AggerateLockerItemViewModelHandler(IMediator mediator,
|
||||
IServiceProvider serviceProvider,
|
||||
ICache<Item> cache,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel,
|
||||
ContainerViewModelConfiguration>>
|
||||
LockerViewModelConfiguration>>
|
||||
{
|
||||
public async Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
||||
ContainerViewModelConfiguration> args)
|
||||
LockerViewModelConfiguration> args)
|
||||
{
|
||||
if (args.Options is ContainerViewModelConfiguration configuration)
|
||||
if (args.Options is LockerViewModelConfiguration configuration)
|
||||
{
|
||||
cache.Clear();
|
||||
bool selected = true;
|
||||
|
||||
if (await mediator.Handle<RequestEventArgs<QueryContainerConfiguration>,
|
||||
IReadOnlyCollection<(Guid Id, string Name, bool Favourite, bool Archived)>>(Request.As(new QueryContainerConfiguration
|
||||
if (await mediator.Handle<RequestEventArgs<QueryLockerConfiguration>,
|
||||
IReadOnlyCollection<(Guid Id, string Name, bool Favourite, bool Archived)>>(Request.As(new QueryLockerConfiguration
|
||||
{
|
||||
Filter = configuration.Filter,
|
||||
Query = configuration.Query
|
||||
@@ -4,19 +4,19 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateMainViewModelHandler(IPublisher publisher,
|
||||
IContainerHostCollection containers) :
|
||||
ILockerHostCollection lockers) :
|
||||
INotificationHandler<AggerateEventArgs<IMainNavigationViewModel>>
|
||||
{
|
||||
public Task Handle(AggerateEventArgs<IMainNavigationViewModel> args)
|
||||
{
|
||||
foreach (IComponentHost container in containers.OrderBy(x => x.GetConfiguration<ContainerConfiguration>()
|
||||
is ContainerConfiguration configuration ? configuration.Name : null))
|
||||
foreach (IComponentHost locker in lockers.OrderBy(x => x.GetConfiguration<LockerConfiguration>()
|
||||
is LockerConfiguration configuration ? configuration.Name : null))
|
||||
{
|
||||
if (container.Services.GetRequiredService<ContainerConfiguration>() is ContainerConfiguration configuration)
|
||||
if (locker.Services.GetRequiredService<LockerConfiguration>() is LockerConfiguration configuration)
|
||||
{
|
||||
if (container.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||
if (locker.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||
{
|
||||
if (factory.Create<ContainerNavigationViewModel>(configuration.Name) is ContainerNavigationViewModel viewModel)
|
||||
if (factory.Create<LockerNavigationViewModel>(configuration.Name) is LockerNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(Create.As<IMainNavigationViewModel>(viewModel),
|
||||
nameof(MainViewModel));
|
||||
|
||||
@@ -8,4 +8,4 @@ public partial class AllNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string filter) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||
string filter) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||
@@ -8,4 +8,4 @@ public partial class ArchiveNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -8,4 +8,4 @@ public partial class CategoriesNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -1,8 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class CommandCollection(IList<IDisposable> list) :
|
||||
ReadOnlyCollection<IDisposable>(list)
|
||||
{
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerActivatedHandler(IContainerHostCollection containers,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ActivatedEventArgs<IComponentHost>>
|
||||
{
|
||||
public Task Handle(ActivatedEventArgs<IComponentHost> args)
|
||||
{
|
||||
if (args.Value is IComponentHost container)
|
||||
{
|
||||
List<IComponentHost> sortedContainers = [.. containers, container];
|
||||
sortedContainers = [.. sortedContainers.OrderBy(x => x.GetConfiguration<ContainerConfiguration>() is ContainerConfiguration configuration ? configuration.Name : null)];
|
||||
|
||||
int index = sortedContainers.IndexOf(container);
|
||||
|
||||
if (container.Services.GetRequiredService<ContainerConfiguration>() is ContainerConfiguration configuration)
|
||||
{
|
||||
if (container.Services.GetRequiredService<IServiceFactory>() is IServiceFactory serviceFactory)
|
||||
{
|
||||
if (serviceFactory.Create<ContainerNavigationViewModel>(configuration.Name) is ContainerNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(new InsertEventArgs<IMainNavigationViewModel>(index, viewModel),
|
||||
nameof(MainViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerComponent(IComponentBuilder builder) : Component(builder),
|
||||
IContainerComponent;
|
||||
@@ -1,18 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerFactory(IComponentFactory componentFactory) :
|
||||
IContainerFactory
|
||||
{
|
||||
public IComponentHost? Create(string name)
|
||||
{
|
||||
if (componentFactory.Create<IContainerComponent, ContainerConfiguration>($"Locker:{name}",
|
||||
new ContainerConfiguration { Name = name }) is IComponentHost host)
|
||||
{
|
||||
return host;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ContainerHeaderViewModel :
|
||||
ObservableCollection
|
||||
{
|
||||
public ContainerHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
|
||||
Add<CreateItemActionViewModel>(0);
|
||||
Add<SearchContainerActionViewModel>(2);
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerInitializer(IEnumerable<IConfigurationDescriptor<ContainerConfiguration>> configurations,
|
||||
IComponentFactory componentFactory,
|
||||
IContainerHostCollection vaults) : IInitializer
|
||||
{
|
||||
public async Task Initialize()
|
||||
{
|
||||
foreach (IConfigurationDescriptor<ContainerConfiguration> configuration in configurations)
|
||||
{
|
||||
if (componentFactory.Create<IContainerComponent,
|
||||
ContainerConfiguration>(configuration.Section, configuration.Value)
|
||||
is IComponentHost host)
|
||||
{
|
||||
vaults.Add(host);
|
||||
await host.StartAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,10 @@ public partial class CreateItemActionViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
NamedComponent named,
|
||||
int index) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
NamedComponent named) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = index;
|
||||
private int index = 0;
|
||||
|
||||
[ObservableProperty]
|
||||
private string named = $"{named}";
|
||||
|
||||
@@ -5,7 +5,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class CreateItemHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||
public class CreateItemHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IHandler<CreateEventArgs<(Guid, ItemConfiguration)>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(CreateEventArgs<(Guid, ItemConfiguration)> args,
|
||||
@@ -17,7 +17,7 @@ public class CreateItemHandler(IDbContextFactory<ContainerDbContext> dbContextFa
|
||||
{
|
||||
string? name = configuration.Name;
|
||||
|
||||
using ContainerDbContext context = dbContextFactory.CreateDbContext();
|
||||
using LockerContext context = dbContextFactory.CreateDbContext();
|
||||
EntityEntry<ItemEntry>? result = null;
|
||||
|
||||
await Task.Run(async () =>
|
||||
|
||||
@@ -5,30 +5,30 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class CreateContainerHandler(IContainerFactory componentFactory,
|
||||
public class CreateLockerHandler(ILockerFactory componentFactory,
|
||||
IPublisher publisher) :
|
||||
IHandler<CreateEventArgs<Container>, bool>
|
||||
IHandler<CreateEventArgs<Locker>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(CreateEventArgs<Container> args,
|
||||
public async Task<bool> Handle(CreateEventArgs<Locker> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is Container container && container.Name is { Length: > 0 } name &&
|
||||
container.Password is { Length: > 0 } password)
|
||||
if (args.Value is Locker locker && locker.Name is { Length: > 0 } name &&
|
||||
locker.Password is { Length: > 0 } password)
|
||||
{
|
||||
if (componentFactory.Create(name) is IComponentHost host)
|
||||
{
|
||||
ISecurityKeyFactory keyVaultFactory = host.Services.GetRequiredService<ISecurityKeyFactory>();
|
||||
IValueStore<SecurityKey> secureKeyStore = host.Services.GetRequiredService<IValueStore<SecurityKey>>();
|
||||
IContainerStorageFactory containerFactory = host.Services.GetRequiredService<IContainerStorageFactory>();
|
||||
ILockerStorageFactory lockerStorageFactory = host.Services.GetRequiredService<ILockerStorageFactory>();
|
||||
|
||||
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password)) is SecurityKey key)
|
||||
{
|
||||
secureKeyStore.Set(key);
|
||||
|
||||
if (await containerFactory.Create(name, key))
|
||||
if (await lockerStorageFactory.Create(name, key))
|
||||
{
|
||||
IWritableConfiguration<ContainerConfiguration> configuration =
|
||||
host.Services.GetRequiredService<IWritableConfiguration<ContainerConfiguration>>();
|
||||
IWritableConfiguration<LockerConfiguration> configuration =
|
||||
host.Services.GetRequiredService<IWritableConfiguration<LockerConfiguration>>();
|
||||
|
||||
configuration.Write(args => args.Key = $"{Convert.ToBase64String(key.Salt)}:{Convert.ToBase64String(key.EncryptedKey)}:{Convert.ToBase64String(key.DecryptedKey)}");
|
||||
host.Start();
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class CreateContainerNavigationViewModel(IServiceProvider provider,
|
||||
public partial class CreateLockerNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class CreateContainerViewModel(IServiceProvider provider,
|
||||
public partial class CreateLockerViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IPublisher publisher,
|
||||
IMediator mediator,
|
||||
@@ -22,5 +22,5 @@ public partial class CreateContainerViewModel(IServiceProvider provider,
|
||||
private string password;
|
||||
|
||||
public async Task<bool> Confirm() =>
|
||||
await Mediator.Handle<CreateEventArgs<Container>, bool>(Create.As(new Container(Name, Password)));
|
||||
await Mediator.Handle<CreateEventArgs<Locker>, bool>(Create.As(new Locker(Name, Password)));
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class CreatedItemHandler(IServiceProvider serviceProvider,
|
||||
int index = cache.IndexOf(item);
|
||||
valueStore.Set(item);
|
||||
|
||||
publisher.Publish(Insert.As(index, viewModel), nameof(ContainerViewModel));
|
||||
publisher.Publish(Insert.As(index, viewModel), nameof(LockerViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record DropdownEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string[]? Values { get; set; }
|
||||
}
|
||||
+7
-7
@@ -4,10 +4,10 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class FilterContainerNavigationViewModel : Observable,
|
||||
IContainerNavigationViewModel,
|
||||
INotificationHandler<ActivatedEventArgs<Container>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Container>>
|
||||
public partial class FilterLockerNavigationViewModel : Observable,
|
||||
ILockerNavigationViewModel,
|
||||
INotificationHandler<ActivatedEventArgs<Locker>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Locker>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool activated;
|
||||
@@ -18,7 +18,7 @@ public partial class FilterContainerNavigationViewModel : Observable,
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
public FilterContainerNavigationViewModel(IServiceProvider provider,
|
||||
public FilterLockerNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -29,10 +29,10 @@ public partial class FilterContainerNavigationViewModel : Observable,
|
||||
Filter = filter;
|
||||
}
|
||||
|
||||
public Task Handle(DeactivatedEventArgs<Container> args) =>
|
||||
public Task Handle(DeactivatedEventArgs<Locker> args) =>
|
||||
Task.FromResult(Activated = false);
|
||||
|
||||
public Task Handle(ActivatedEventArgs<Container> args) =>
|
||||
public Task Handle(ActivatedEventArgs<Locker> args) =>
|
||||
Task.FromResult(Activated = true);
|
||||
|
||||
[RelayCommand]
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record Form
|
||||
{
|
||||
public ICollection<FormEntry>? Entries { get; set; }
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record FormEntry;
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record FormField : FormEntry
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public object? Value { get; set; }
|
||||
|
||||
public FormFieldType Type { get; set; }
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public enum FormFieldType
|
||||
{
|
||||
Attachments,
|
||||
Date,
|
||||
Masked,
|
||||
Note,
|
||||
Number,
|
||||
Options,
|
||||
Password,
|
||||
Phone,
|
||||
Text,
|
||||
Time,
|
||||
Url
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record FormGroup : FormEntry
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public ICollection<FormField>? Fields { get; set; }
|
||||
}
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerHost : IComponentHost;
|
||||
public interface ILockerComponent : IComponent;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault
|
||||
{
|
||||
public interface IContainerFactory
|
||||
public interface ILockerFactory
|
||||
{
|
||||
IComponentHost? Create(string name);
|
||||
}
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerComponent : IComponent;
|
||||
public interface ILockerHost : IComponentHost;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerHostCollection :
|
||||
public interface ILockerHostCollection :
|
||||
IEnumerable<IComponentHost>
|
||||
{
|
||||
void Add(IComponentHost host);
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerNavigationViewModel :
|
||||
public interface ILockerNavigationViewModel :
|
||||
ISelectable,
|
||||
IDisposable;
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerStorageFactory
|
||||
public interface ILockerStorageFactory
|
||||
{
|
||||
Task<bool> Create(string name, SecurityKey key);
|
||||
}
|
||||
@@ -14,4 +14,14 @@ public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
||||
{
|
||||
[ObservableProperty]
|
||||
private IContentTemplate template = template;
|
||||
|
||||
public override Task OnActivated()
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<LockerCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
|
||||
})));
|
||||
|
||||
return base.OnActivated();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public partial class ItemCollectionViewModel :
|
||||
INotificationHandler<NotifyEventArgs<Filter>>,
|
||||
INotificationHandler<NotifyEventArgs<Search>>
|
||||
{
|
||||
private ContainerViewModelConfiguration configuration;
|
||||
private LockerViewModelConfiguration configuration;
|
||||
|
||||
public ItemCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
@@ -17,7 +17,7 @@ public partial class ItemCollectionViewModel :
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
ContainerViewModelConfiguration configuration,
|
||||
LockerViewModelConfiguration configuration,
|
||||
string? filter = null) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
@@ -48,7 +48,18 @@ public partial class ItemCollectionViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override IAggerate OnPrepareAggregation(object? key) =>
|
||||
Aggerate.With<ItemNavigationViewModel, ContainerViewModelConfiguration>(configuration)
|
||||
public override Task OnActivated()
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<LockerCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<CreateItemActionViewModel>(),
|
||||
Factory.Create<SearchLockerActionViewModel>(),
|
||||
})));
|
||||
|
||||
return base.OnActivated();
|
||||
}
|
||||
|
||||
protected override IAggerate OnAggerate(object? key) =>
|
||||
Aggerate.With<ItemNavigationViewModel, LockerViewModelConfiguration>(configuration)
|
||||
with { Key = key };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ItemCommandHeaderCollection(IList<IDisposable> list) :
|
||||
ReadOnlyCollection<IDisposable>(list);
|
||||
@@ -10,14 +10,15 @@ public partial class ItemCommandHeaderViewModel(IServiceProvider provider,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<NotifyEventArgs<CommandCollection>>
|
||||
INotificationHandler<NotifyEventArgs<ItemCommandHeaderCollection>>
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(NotifyEventArgs<CommandCollection> args)
|
||||
public Task Handle(NotifyEventArgs<ItemCommandHeaderCollection> args)
|
||||
{
|
||||
Clear();
|
||||
if (args.Value is CommandCollection commandCollection)
|
||||
|
||||
if (args.Value is ItemCommandHeaderCollection commandCollection)
|
||||
{
|
||||
foreach (IDisposable command in commandCollection)
|
||||
{
|
||||
|
||||
@@ -3,4 +3,40 @@
|
||||
public record ItemConfiguration
|
||||
{
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public IList<ItemSectionConfiguration>? Sections { get; set; }
|
||||
|
||||
public static ItemConfiguration CreditCard => new()
|
||||
{
|
||||
Name = "Credit Card",
|
||||
Sections = new List<ItemSectionConfiguration>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
Label = "Cardholder name"
|
||||
},
|
||||
new DropdownEntryConfiguration
|
||||
{
|
||||
Label = "Type",
|
||||
},
|
||||
new MaskedTextEntryConfiguration
|
||||
{
|
||||
Label = "Card number"
|
||||
},
|
||||
new MaskedTextEntryConfiguration
|
||||
{
|
||||
Label = "Expiry date"
|
||||
},
|
||||
new MaskedTextEntryConfiguration
|
||||
{
|
||||
Label = "Card verification code"
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[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
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Label { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public object? Value { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record ItemSectionConfiguration
|
||||
{
|
||||
public IList<ItemEntryConfiguration> Entries { get; set; } = new List<ItemEntryConfiguration>();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public partial class ItemViewModel :
|
||||
|
||||
public Task Handle(UpdateEventArgs<Item> args)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<ConfirmItemActionViewModel>(),
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
@@ -63,7 +63,7 @@ public partial class ItemViewModel :
|
||||
|
||||
public Task Handle(CancelEventArgs<Item> args)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<EditItemActionViewModel>(),
|
||||
Factory.Create<ArchiveItemActionViewModel>(),
|
||||
@@ -74,7 +74,7 @@ public partial class ItemViewModel :
|
||||
|
||||
public Task Handle(ConfirmEventArgs<Item> args)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||
Factory.Create<EditItemActionViewModel>(),
|
||||
@@ -88,7 +88,7 @@ public partial class ItemViewModel :
|
||||
{
|
||||
if (!Immutable)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<ConfirmItemActionViewModel>(),
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
@@ -96,14 +96,14 @@ public partial class ItemViewModel :
|
||||
}
|
||||
else if (Archived)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<UnarchiveItemActionViewModel>(),
|
||||
})));
|
||||
}
|
||||
else
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||
Factory.Create<EditItemActionViewModel>(),
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record Container
|
||||
public record Locker
|
||||
{
|
||||
public Container(string name, string password)
|
||||
public Locker(string name, string password)
|
||||
{
|
||||
Name = name;
|
||||
Password = password;
|
||||
}
|
||||
|
||||
public Container(string password)
|
||||
public Locker(string password)
|
||||
{
|
||||
Password = password;
|
||||
}
|
||||
|
||||
public Container()
|
||||
public Locker()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerActivatedHandler(ILockerHostCollection lockers,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ActivatedEventArgs<IComponentHost>>
|
||||
{
|
||||
public Task Handle(ActivatedEventArgs<IComponentHost> args)
|
||||
{
|
||||
if (args.Value is IComponentHost locker)
|
||||
{
|
||||
List<IComponentHost> sortedLockers = [.. lockers, locker];
|
||||
sortedLockers = [.. sortedLockers.OrderBy(x => x.GetConfiguration<LockerConfiguration>() is LockerConfiguration configuration ? configuration.Name : null)];
|
||||
|
||||
int index = sortedLockers.IndexOf(locker);
|
||||
|
||||
if (locker.Services.GetRequiredService<LockerConfiguration>() is LockerConfiguration configuration)
|
||||
{
|
||||
if (locker.Services.GetRequiredService<IServiceFactory>() is IServiceFactory serviceFactory)
|
||||
{
|
||||
if (serviceFactory.Create<LockerNavigationViewModel>(configuration.Name) is LockerNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(new InsertEventArgs<IMainNavigationViewModel>(index, viewModel),
|
||||
nameof(MainViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerCommandHeaderCollection(IList<IDisposable> list) :
|
||||
ReadOnlyCollection<IDisposable>(list);
|
||||
@@ -0,0 +1,6 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerComponent(IComponentBuilder builder) : Component(builder),
|
||||
ILockerComponent;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record ContainerConfiguration :
|
||||
public record LockerConfiguration :
|
||||
ComponentConfiguration
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerConnection(string connection)
|
||||
public class LockerConnection(string connection)
|
||||
{
|
||||
private readonly string connection = connection;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerFactory(IComponentFactory componentFactory) :
|
||||
ILockerFactory
|
||||
{
|
||||
public IComponentHost? Create(string name)
|
||||
{
|
||||
if (componentFactory.Create<ILockerComponent, LockerConfiguration>($"Locker:{name}",
|
||||
new LockerConfiguration { Name = name }) is IComponentHost host)
|
||||
{
|
||||
return host;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class LockerHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<NotifyEventArgs<LockerCommandHeaderCollection>>
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(NotifyEventArgs<LockerCommandHeaderCollection> args)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (args.Value is LockerCommandHeaderCollection commandCollection)
|
||||
{
|
||||
foreach (IDisposable command in commandCollection)
|
||||
{
|
||||
Add(command);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerHostCollection :
|
||||
IContainerHostCollection
|
||||
public class LockerHostCollection :
|
||||
ILockerHostCollection
|
||||
|
||||
{
|
||||
private readonly List<IComponentHost> hosts = [];
|
||||
@@ -0,0 +1,22 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerInitializer(IEnumerable<IConfigurationDescriptor<LockerConfiguration>> configurations,
|
||||
IComponentFactory componentFactory,
|
||||
ILockerHostCollection lockers) : IInitializer
|
||||
{
|
||||
public async Task Initialize()
|
||||
{
|
||||
foreach (IConfigurationDescriptor<LockerConfiguration> configuration in configurations)
|
||||
{
|
||||
if (componentFactory.Create<ILockerComponent,
|
||||
LockerConfiguration>(configuration.Section, configuration.Value)
|
||||
is IComponentHost host)
|
||||
{
|
||||
lockers.Add(host);
|
||||
await host.StartAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ContainerNavigationViewModel :
|
||||
ObservableCollection<IContainerNavigationViewModel>,
|
||||
public partial class LockerNavigationViewModel :
|
||||
ObservableCollection<ILockerNavigationViewModel>,
|
||||
IMainNavigationViewModel,
|
||||
INotificationHandler<OpenedEventArgs<Container>>,
|
||||
INotificationHandler<ClosedEventArgs<Container>>,
|
||||
INotificationHandler<ActivatedEventArgs<Container>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Container>>
|
||||
INotificationHandler<OpenedEventArgs<Locker>>,
|
||||
INotificationHandler<ClosedEventArgs<Locker>>,
|
||||
INotificationHandler<ActivatedEventArgs<Locker>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Locker>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool activated;
|
||||
@@ -26,7 +26,7 @@ public partial class ContainerNavigationViewModel :
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
public ContainerNavigationViewModel(IServiceProvider provider,
|
||||
public LockerNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -41,7 +41,7 @@ public partial class ContainerNavigationViewModel :
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
public Task Handle(OpenedEventArgs<Container> args)
|
||||
public Task Handle(OpenedEventArgs<Locker> args)
|
||||
{
|
||||
Add<AllNavigationViewModel>("All");
|
||||
Add<StarredNavigationViewModel>("Starred");
|
||||
@@ -52,7 +52,7 @@ public partial class ContainerNavigationViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(ClosedEventArgs<Container> args)
|
||||
public Task Handle(ClosedEventArgs<Locker> args)
|
||||
{
|
||||
Opened = true;
|
||||
Clear();
|
||||
@@ -60,9 +60,9 @@ public partial class ContainerNavigationViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(DeactivatedEventArgs<Container> args) =>
|
||||
public Task Handle(DeactivatedEventArgs<Locker> args) =>
|
||||
Task.FromResult(Activated = false);
|
||||
|
||||
public Task Handle(ActivatedEventArgs<Container> args) =>
|
||||
public Task Handle(ActivatedEventArgs<Locker> args) =>
|
||||
Task.FromResult(Activated = true);
|
||||
}
|
||||
@@ -6,19 +6,19 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerStorageFactory(IValueStore<ContainerConnection> connection,
|
||||
public class LockerStorageFactory(IValueStore<LockerConnection> connection,
|
||||
IHostEnvironment environment,
|
||||
IServiceProvider provider) :
|
||||
IContainerStorageFactory
|
||||
ILockerStorageFactory
|
||||
{
|
||||
public async Task<bool> Create(string name,
|
||||
SecurityKey key)
|
||||
{
|
||||
connection.Set(new ContainerConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||
connection.Set(new LockerConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||
$".vault;Mode=ReadWriteCreate;Pooling=false;Password={Convert.ToBase64String(key.DecryptedKey)}"));
|
||||
|
||||
IDbContextFactory<ContainerDbContext> dbContextFactory = provider.GetRequiredService<IDbContextFactory<ContainerDbContext>>();
|
||||
using ContainerDbContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
IDbContextFactory<LockerContext> dbContextFactory = provider.GetRequiredService<IDbContextFactory<LockerContext>>();
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ContainerViewModel :
|
||||
public partial class LockerViewModel :
|
||||
Observable
|
||||
{
|
||||
[ObservableProperty]
|
||||
@@ -11,7 +11,7 @@ public partial class ContainerViewModel :
|
||||
|
||||
[ObservableProperty]
|
||||
private string filter;
|
||||
public ContainerViewModel(IServiceProvider provider,
|
||||
public LockerViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -26,13 +26,13 @@ public partial class ContainerViewModel :
|
||||
|
||||
public override async Task OnActivated()
|
||||
{
|
||||
Publisher.Publish(Activated.As<Container>());
|
||||
Publisher.Publish(Activated.As<Locker>());
|
||||
await base.OnActivated();
|
||||
}
|
||||
|
||||
public override async Task OnDeactivated()
|
||||
{
|
||||
Publisher.Publish(Deactivated.As<Container>());
|
||||
Publisher.Publish(Deactivated.As<Locker>());
|
||||
await base.OnDeactivated();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record ContainerViewModelConfiguration
|
||||
public record LockerViewModelConfiguration
|
||||
{
|
||||
public string? Filter { get; set; } = "All";
|
||||
|
||||
@@ -16,7 +16,7 @@ public partial class ManageViewModel :
|
||||
{
|
||||
Template = template;
|
||||
|
||||
Add<CreateContainerNavigationViewModel>();
|
||||
Add<CreateLockerNavigationViewModel>();
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record MaskedTextEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Pattern { get; set; }
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class ModifiedItemHandler(IServiceProvider serviceProvider,
|
||||
int newIndex = cache.IndexOf(newItem);
|
||||
valueStore.Set(newItem);
|
||||
|
||||
publisher.Publish(MoveTo.As<ItemNavigationViewModel>(oldIndex, newIndex), nameof(ContainerViewModel));
|
||||
publisher.Publish(MoveTo.As<ItemNavigationViewModel>(oldIndex, newIndex), nameof(LockerViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record NoteEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record NumberEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using System.Text;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class OpenContainerHandler(ContainerConfiguration configuration,
|
||||
ISecurityKeyFactory keyVaultFactory,
|
||||
IContainerStorageFactory vaultStorage) :
|
||||
IHandler<ActivateEventArgs<Container>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(ActivateEventArgs<Container> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is Container container && configuration.Name is { Length: > 0 } name && container.Password is { Length: > 0 } password)
|
||||
{
|
||||
if (configuration.Key?.Split(':') is { Length: >= 2 } keyPart)
|
||||
{
|
||||
byte[]? salt = Convert.FromBase64String(keyPart[0]);
|
||||
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
|
||||
|
||||
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
|
||||
{
|
||||
if (await vaultStorage.Create(name, key))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Text;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class OpenLockerHandler(LockerConfiguration configuration,
|
||||
ISecurityKeyFactory securityKeyFactory,
|
||||
ILockerStorageFactory lockerStorageFactory) :
|
||||
IHandler<ActivateEventArgs<Locker>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(ActivateEventArgs<Locker> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is Locker locker && configuration.Name is { Length: > 0 } name && locker.Password is { Length: > 0 } password)
|
||||
{
|
||||
if (configuration.Key?.Split(':') is { Length: >= 2 } keyPart)
|
||||
{
|
||||
byte[]? salt = Convert.FromBase64String(keyPart[0]);
|
||||
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
|
||||
|
||||
if (securityKeyFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
|
||||
{
|
||||
if (await lockerStorageFactory.Create(name, key))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class OpenContainerViewModel(IServiceProvider provider,
|
||||
public partial class OpenLockerViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -20,9 +20,9 @@ public partial class OpenContainerViewModel(IServiceProvider provider,
|
||||
{
|
||||
if (Password is { Length: > 0 })
|
||||
{
|
||||
if (await Mediator.Handle<ActivateEventArgs<Container>, bool>(Activate.As(new Container(Password))))
|
||||
if (await Mediator.Handle<ActivateEventArgs<Locker>, bool>(Activate.As(new Locker(Password))))
|
||||
{
|
||||
Publisher.Publish(Opened.As<Container>());
|
||||
Publisher.Publish(Opened.As<Locker>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record PasswordEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record QueryContainerConfiguration
|
||||
public record QueryLockerConfiguration
|
||||
{
|
||||
public string? Filter { get; set; }
|
||||
|
||||
@@ -5,15 +5,15 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||
IHandler<RequestEventArgs<QueryContainerConfiguration>, IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>>
|
||||
public class QueryLockerHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IHandler<RequestEventArgs<QueryLockerConfiguration>, IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>>
|
||||
{
|
||||
public async Task<IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>> Handle(RequestEventArgs<QueryContainerConfiguration> args,
|
||||
public async Task<IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>> Handle(RequestEventArgs<QueryLockerConfiguration> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
List<(Guid Id, string? Name, bool Favourite, bool Archived)> items = [];
|
||||
|
||||
if (args.Value is QueryContainerConfiguration queryConfiguration)
|
||||
if (args.Value is QueryLockerConfiguration queryConfiguration)
|
||||
{
|
||||
ExpressionStarter<ItemEntry> predicate =
|
||||
PredicateBuilder.New<ItemEntry>(true);
|
||||
@@ -40,7 +40,7 @@ public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbConte
|
||||
|
||||
var results = await Task.Run(async () =>
|
||||
{
|
||||
using ContainerDbContext context = dbContextFactory.CreateDbContext();
|
||||
using LockerContext context = dbContextFactory.CreateDbContext();
|
||||
return await context.Set<ItemEntry>()
|
||||
.Where(predicate)
|
||||
.Select(x => new
|
||||
@@ -1,21 +0,0 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class SearchContainerActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
int index) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = index;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class SearchLockerActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = 2;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
|
||||
public partial class BackContainerActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = 2;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
@@ -8,4 +8,4 @@ public partial class StarredNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record TextEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
public class UnarchiveItemHandler(IValueStore<Item> valueStore,
|
||||
IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||
IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
INotificationHandler<UnarchiveEventArgs<Item>>
|
||||
{
|
||||
public async Task Handle(UnarchiveEventArgs<Item> args)
|
||||
@@ -16,7 +16,7 @@ public class UnarchiveItemHandler(IValueStore<Item> valueStore,
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
using ContainerDbContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
|
||||
if (await context.FindAsync<ItemEntry>(item.Id) is ItemEntry result)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class UpdateItemHander(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||
public class UpdateItemHander(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IHandler<UpdateEventArgs<(Guid, ItemConfiguration)>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(UpdateEventArgs<(Guid, ItemConfiguration)> args,
|
||||
@@ -15,7 +15,7 @@ public class UpdateItemHander(IDbContextFactory<ContainerDbContext> dbContextFac
|
||||
try
|
||||
{
|
||||
string? name = configuration.Name;
|
||||
using ContainerDbContext context = dbContextFactory.CreateDbContext();
|
||||
using LockerContext context = dbContextFactory.CreateDbContext();
|
||||
ItemEntry? result = null;
|
||||
|
||||
await Task.Run(async () =>
|
||||
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class UpdateItemStateHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||
public class UpdateItemStateHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IHandler<UpdateEventArgs<(Guid, int)>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(UpdateEventArgs<(Guid, int)> args,
|
||||
@@ -14,7 +14,7 @@ public class UpdateItemStateHandler(IDbContextFactory<ContainerDbContext> dbCont
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
using ContainerDbContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
if (await context.FindAsync<ItemEntry>(id) is ItemEntry result)
|
||||
{
|
||||
result.State = state;
|
||||
|
||||
Reference in New Issue
Block a user