Worlds fastest rename
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="Locker">
|
||||
<NavigateAction Region="Main" Route="Wallet">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
|
||||
@@ -26,7 +26,7 @@ public partial class App : Application
|
||||
public override async void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
IHost? host = DefaultHostBuilder.Create()
|
||||
.AddConfiguration<LockerConfiguration>("Locker:*")
|
||||
.AddConfiguration<WalletConfiguration>("Wallet:*")
|
||||
.AddConfiguration<ItemConfiguration>("Item:*")
|
||||
.AddConfiguration("Item:Bank Account", ItemConfiguration.BankAccount)
|
||||
.AddConfiguration("Item:Credit Card", ItemConfiguration.CreditCard)
|
||||
@@ -58,9 +58,9 @@ public partial class App : Application
|
||||
services.AddTemplate<MainWindowViewModel, MainWindow>("MainWindow");
|
||||
}
|
||||
|
||||
services.AddHandler<LockerActivatedHandler>();
|
||||
services.AddHandler<WalletActivatedHandler>();
|
||||
|
||||
services.AddTransient<ILockerComponent>(provider => Component.Create<LockerComponent>(provider, args =>
|
||||
services.AddTransient<IWalletComponent>(provider => Component.Create<WalletComponent>(provider, args =>
|
||||
{
|
||||
args.AddServices(services =>
|
||||
{
|
||||
@@ -80,7 +80,7 @@ public partial class App : Application
|
||||
services.AddTransient<IKeyDeriver, KeyDeriver>();
|
||||
|
||||
services.AddTransient<ISecurityKeyFactory, SecurityKeyFactory>();
|
||||
services.AddTransient<ILockerStorageFactory, LockerStorageFactory>();
|
||||
services.AddTransient<IWalletStorageFactory, WalletStorageFactory>();
|
||||
|
||||
services.AddTransient<IItemConfigurationCollection, ItemConfigurationCollection>(provider =>
|
||||
{
|
||||
@@ -92,44 +92,44 @@ public partial class App : Application
|
||||
});
|
||||
|
||||
services.TryAddSingleton<IDecoratorService<SecurityKey>, DecoratorService<SecurityKey>>();
|
||||
services.TryAddSingleton<IDecoratorService<LockerConnection>, DecoratorService<LockerConnection>>();
|
||||
services.TryAddSingleton<IDecoratorService<WalletConnection>, DecoratorService<WalletConnection>>();
|
||||
|
||||
services.AddDbContextFactory<LockerContext>((provider, args) =>
|
||||
services.AddDbContextFactory<WalletContext>((provider, args) =>
|
||||
{
|
||||
if (provider.GetRequiredService<IDecoratorService<LockerConnection>>()
|
||||
is IDecoratorService<LockerConnection> connection)
|
||||
if (provider.GetRequiredService<IDecoratorService<WalletConnection>>()
|
||||
is IDecoratorService<WalletConnection> connection)
|
||||
{
|
||||
args.UseSqlite($"{connection.Service}");
|
||||
}
|
||||
});
|
||||
|
||||
services.AddHandler<QueryLockerHandler>();
|
||||
services.AddHandler<QueryWalletHandler>();
|
||||
services.AddHandler<RequestItemHandler>();
|
||||
services.AddHandler<CreateItemHandler>();
|
||||
services.AddHandler<UpdateItemHander>();
|
||||
services.AddHandler<UpdateItemStateHandler>();
|
||||
|
||||
services.AddHandler<OpenLockerHandler>();
|
||||
services.AddHandler<OpenWalletHandler>();
|
||||
|
||||
services.AddTemplate<LockerNavigationViewModel, LockerNavigationView>();
|
||||
services.AddTemplate<WalletNavigationViewModel, WalletNavigationView>();
|
||||
services.AddTemplate<AllNavigationViewModel, AllNavigationView>();
|
||||
services.AddTemplate<StarredNavigationViewModel, StarredNavigationView>();
|
||||
services.AddTemplate<CategoriesNavigationViewModel, CategoriesNavigationView>();
|
||||
services.AddTemplate<ArchiveNavigationViewModel, ArchiveNavigationView>();
|
||||
|
||||
services.AddTemplate<OpenLockerViewModel, OpenLockerView>("OpenLocker");
|
||||
services.AddTemplate<OpenWalletViewModel, OpenWalletView>("OpenWallet");
|
||||
|
||||
services.AddScoped<LockerViewModelConfiguration>();
|
||||
services.AddScoped<WalletViewModelConfiguration>();
|
||||
|
||||
services.AddTemplate<LockerViewModel, LockerView>("Locker");
|
||||
services.AddTemplate<WalletViewModel, WalletView>("Wallet");
|
||||
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
||||
|
||||
services.AddHandler<SynchronizeItemViewModelHandler>();
|
||||
|
||||
services.AddTemplate<LockerHeaderViewModel, LockerHeaderView>("LockerHeader");
|
||||
services.AddTemplate<WalletHeaderViewModel, WalletHeaderView>("WalletHeader");
|
||||
services.AddTemplate<BackActionViewModel, BackActionView>();
|
||||
services.AddTemplate<CreateItemActionViewModel, CreateItemActionView>();
|
||||
services.AddTemplate<SearchLockerActionViewModel, SearchLockerActionView>();
|
||||
services.AddTemplate<SearchWalletActionViewModel, SearchWalletActionView>();
|
||||
|
||||
services.AddTemplate<ItemCategoryCollectionViewModel, ItemCategoryCollectionView>("ItemCategoryCollection");
|
||||
services.AddTemplate<ItemCategoryNavigationViewModel, ItemCategoryNavigationView>();
|
||||
@@ -191,11 +191,11 @@ public partial class App : Application
|
||||
});
|
||||
})!);
|
||||
|
||||
services.AddTransient<ILockerFactory, LockerFactory>();
|
||||
services.AddHandler<CreateLockerHandler>();
|
||||
services.AddTransient<IWalletFactory, WalletFactory>();
|
||||
services.AddHandler<CreateWalletHandler>();
|
||||
|
||||
services.AddSingleton<ILockerHostCollection, LockerHostCollection>();
|
||||
services.AddInitializer<LockerInitializer>();
|
||||
services.AddSingleton<IWalletHostCollection, WalletHostCollection>();
|
||||
services.AddInitializer<WalletInitializer>();
|
||||
|
||||
services.AddTemplate<MainViewModel, MainView>("Main");
|
||||
services.AddHandler<SynchronizeMainViewModelHandler>();
|
||||
@@ -205,8 +205,8 @@ public partial class App : Application
|
||||
services.AddTemplate<ManageNavigationViewModel, ManageNavigationView>();
|
||||
services.AddTemplate<ManageViewModel, ManageView>("Manage");
|
||||
|
||||
services.AddTemplate<CreateLockerNavigationViewModel, CreateLockerNavigationView>();
|
||||
services.AddTemplate<CreateLockerViewModel, CreateLockerView>("CreateLocker");
|
||||
services.AddTemplate<CreateWalletNavigationViewModel, CreateWalletNavigationView>();
|
||||
services.AddTemplate<CreateWalletViewModel, CreateWalletView>("CreateWallet");
|
||||
})
|
||||
.Build();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="Locker">
|
||||
<NavigateAction Region="Main" Route="Wallet">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
|
||||
@@ -58,11 +58,11 @@
|
||||
<Compile Update="ConfirmItemActionView.axaml.cs">
|
||||
<DependentUpon>ConfirmItemActionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="CreateLockerNavigationView.axaml.cs">
|
||||
<DependentUpon>CreateLockerNavigationView.axaml</DependentUpon>
|
||||
<Compile Update="CreateWalletNavigationView.axaml.cs">
|
||||
<DependentUpon>CreateWalletNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="CreateLockerView.axaml.cs">
|
||||
<DependentUpon>CreateLockerView.axaml</DependentUpon>
|
||||
<Compile Update="CreateWalletView.axaml.cs">
|
||||
<DependentUpon>CreateWalletView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="DismissItemActionView.axaml.cs">
|
||||
<DependentUpon>DismissItemActionView.axaml</DependentUpon>
|
||||
@@ -85,14 +85,14 @@
|
||||
<Compile Update="MaskedTextEntryView.axaml.cs">
|
||||
<DependentUpon>MaskedTextEntryView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="OpenLockerView.axaml.cs">
|
||||
<DependentUpon>OpenLockerView.axaml</DependentUpon>
|
||||
<Compile Update="OpenWalletView.axaml.cs">
|
||||
<DependentUpon>OpenWalletView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ManageNavigationView.axaml.cs">
|
||||
<DependentUpon>ManageNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="LockerHeaderView.axaml.cs">
|
||||
<DependentUpon>LockerHeaderView.axaml</DependentUpon>
|
||||
<Compile Update="WalletHeaderView.axaml.cs">
|
||||
<DependentUpon>WalletHeaderView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ItemNavigationView.axaml.cs">
|
||||
<DependentUpon>ItemNavigationView.axaml</DependentUpon>
|
||||
@@ -100,14 +100,14 @@
|
||||
<Compile Update="ItemView.axaml.cs">
|
||||
<DependentUpon>ItemView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="LockerNavigationView.axaml.cs">
|
||||
<DependentUpon>LockerNavigationView.axaml</DependentUpon>
|
||||
<Compile Update="WalletNavigationView.axaml.cs">
|
||||
<DependentUpon>WalletNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="LockerView.axaml.cs">
|
||||
<DependentUpon>LockerView.axaml</DependentUpon>
|
||||
<Compile Update="WalletView.axaml.cs">
|
||||
<DependentUpon>WalletView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="SearchLockerActionView.axaml.cs">
|
||||
<DependentUpon>SearchLockerActionView.axaml</DependentUpon>
|
||||
<Compile Update="SearchWalletActionView.axaml.cs">
|
||||
<DependentUpon>SearchWalletActionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,9 +0,0 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateLockerNavigationView : SettingsExpander
|
||||
{
|
||||
public CreateLockerNavigationView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
<SettingsExpander
|
||||
x:Class="Bitvault.Avalonia.CreateLockerNavigationView"
|
||||
x:Class="Bitvault.Avalonia.CreateWalletNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Description="Keep organized by separating your things into vaults."
|
||||
@@ -8,7 +8,7 @@
|
||||
<Button MinWidth="132" Content="Create vault">
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Click">
|
||||
<NavigateAction Region="self" Route="CreateLocker" />
|
||||
<NavigateAction Region="self" Route="CreateWallet" />
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Button>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateWalletNavigationView : SettingsExpander
|
||||
{
|
||||
public CreateWalletNavigationView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
<ContentDialog
|
||||
x:Class="Bitvault.Avalonia.CreateLockerView"
|
||||
x:Class="Bitvault.Avalonia.CreateWalletView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
Title="Create vault"
|
||||
x:DataType="vm:CreateLockerViewModel"
|
||||
x:DataType="vm:CreateWalletViewModel"
|
||||
CloseButtonText="Cancel"
|
||||
PrimaryButtonText="Create">
|
||||
<StackPanel Width="400">
|
||||
+2
-2
@@ -2,8 +2,8 @@ using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateLockerView : ContentDialog
|
||||
public partial class CreateWalletView : ContentDialog
|
||||
{
|
||||
public CreateLockerView() =>
|
||||
public CreateWalletView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
<Interaction.Behaviors>
|
||||
<AttachedBehaviour>
|
||||
<NavigateRegionAction Name="Main">
|
||||
<NavigateAction Region="Main" Route="Locker" />
|
||||
<NavigateAction Region="Main" Route="Wallet" />
|
||||
</NavigateRegionAction>
|
||||
</AttachedBehaviour>
|
||||
</Interaction.Behaviors>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
x:Class="Bitvault.Avalonia.ManageNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Content="Manage Lockers">
|
||||
Content="Manage Wallets">
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Tapped">
|
||||
<NavigateAction Region="Main" Route="Manage" />
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.OpenLockerView"
|
||||
x:Class="Bitvault.Avalonia.OpenWalletView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:OpenLockerViewModel">
|
||||
x:DataType="vm:OpenWalletViewModel">
|
||||
<StackPanel
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
+2
-2
@@ -2,8 +2,8 @@ using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class OpenLockerView : UserControl
|
||||
public partial class OpenWalletView : UserControl
|
||||
{
|
||||
public OpenLockerView() =>
|
||||
public OpenWalletView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class SearchLockerActionView : UserControl
|
||||
{
|
||||
public SearchLockerActionView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.SearchLockerActionView"
|
||||
x:Class="Bitvault.Avalonia.SearchWalletActionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:SearchLockerActionViewModel">
|
||||
x:DataType="vm:SearchWalletActionViewModel">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class SearchWalletActionView : UserControl
|
||||
{
|
||||
public SearchWalletActionView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="Locker">
|
||||
<NavigateAction Region="Main" Route="Wallet">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.LockerHeaderView"
|
||||
x:Class="Bitvault.Avalonia.WalletHeaderView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:LockerHeaderViewModel">
|
||||
x:DataType="vm:WalletHeaderViewModel">
|
||||
<ItemsControl ItemTemplate="{ReflectionBinding Template}" ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
+2
-2
@@ -2,8 +2,8 @@ using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class LockerHeaderView : UserControl
|
||||
public partial class WalletHeaderView : UserControl
|
||||
{
|
||||
public LockerHeaderView() =>
|
||||
public WalletHeaderView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
+7
-7
@@ -1,11 +1,11 @@
|
||||
<NavigationViewItem
|
||||
x:Class="Bitvault.Avalonia.LockerNavigationView"
|
||||
x:Class="Bitvault.Avalonia.WalletNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:Name="NavigationViewItem"
|
||||
x:DataType="vm:LockerNavigationViewModel"
|
||||
x:DataType="vm:WalletNavigationViewModel"
|
||||
Content="{Binding Name}"
|
||||
IsExpanded="{Binding Expanded}"
|
||||
MenuItemsSource="{Binding}"
|
||||
@@ -19,7 +19,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="OpenLocker">
|
||||
<NavigateAction Region="Main" Route="OpenWallet">
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
</NavigateAction>
|
||||
<ChangePropertyAction
|
||||
@@ -49,7 +49,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Opened}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="OpenLocker">
|
||||
<NavigateAction Region="Main" Route="OpenWallet">
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
@@ -60,7 +60,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="Locker" />
|
||||
<NavigateAction Region="Main" Route="Wallet" />
|
||||
<InvokeNavigationViewItemAction />
|
||||
</ConditionAction>
|
||||
</AttachedBehaviour>
|
||||
@@ -71,7 +71,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Opened}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="OpenLocker">
|
||||
<NavigateAction Region="Main" Route="OpenWallet">
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
@@ -82,7 +82,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="Locker" />
|
||||
<NavigateAction Region="Main" Route="Wallet" />
|
||||
<InvokeNavigationViewItemAction />
|
||||
</ConditionAction>
|
||||
</AttachedEventTriggerBehaviour>
|
||||
+2
-2
@@ -2,8 +2,8 @@ using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class LockerNavigationView : NavigationViewItem
|
||||
public partial class WalletNavigationView : NavigationViewItem
|
||||
{
|
||||
public LockerNavigationView() =>
|
||||
public WalletNavigationView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.LockerView"
|
||||
x:Class="Bitvault.Avalonia.WalletView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:LockerViewModel">
|
||||
x:DataType="vm:WalletViewModel">
|
||||
<Grid
|
||||
x:Name="Container"
|
||||
ColumnDefinitions="320,Auto,*,Auto"
|
||||
@@ -17,7 +17,7 @@
|
||||
<ContentControl VerticalAlignment="Center">
|
||||
<Interaction.Behaviors>
|
||||
<AttachedBehaviour>
|
||||
<NavigateAction Region="{Binding $self}" Route="LockerHeader" />
|
||||
<NavigateAction Region="{Binding $self}" Route="WalletHeader" />
|
||||
</AttachedBehaviour>
|
||||
</Interaction.Behaviors>
|
||||
</ContentControl>
|
||||
@@ -4,9 +4,9 @@ using FluentAvalonia.UI.Windowing;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class LockerView : UserControl
|
||||
public partial class WalletView : UserControl
|
||||
{
|
||||
public LockerView() => InitializeComponent();
|
||||
public WalletView() => InitializeComponent();
|
||||
|
||||
protected override void OnLoaded(RoutedEventArgs args)
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault.Data;
|
||||
|
||||
public class LockerContext(DbContextOptions<LockerContext> options) :
|
||||
public class WalletContext(DbContextOptions<WalletContext> options) :
|
||||
DbContext(options)
|
||||
{
|
||||
public DbSet<BlobEntry> Blobs { get; set; }
|
||||
|
||||
@@ -8,4 +8,4 @@ public partial class AllNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string filter) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||
string filter) : FilterWalletNavigationViewModel(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) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterWalletNavigationViewModel(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) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterWalletNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -7,7 +7,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class CreateItemHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
public class CreateItemHandler(IDbContextFactory<WalletContext> dbContextFactory) :
|
||||
IHandler<CreateEventArgs<(Guid, string, string, ItemConfiguration)>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(CreateEventArgs<(Guid, string, string, ItemConfiguration)> args,
|
||||
@@ -32,7 +32,7 @@ public class CreateItemHandler(IDbContextFactory<LockerContext> dbContextFactory
|
||||
Type = 0,
|
||||
});
|
||||
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
using WalletContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
EntityEntry<ItemEntry>? result = await context.AddAsync(itemEntry, cancellationToken);
|
||||
await context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
|
||||
@@ -5,16 +5,16 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class CreateLockerHandler(ILockerFactory componentFactory,
|
||||
public class CreateWalletHandler(IWalletFactory componentFactory,
|
||||
IPublisher publisher) :
|
||||
IHandler<CreateEventArgs<Locker<(string, string)>>, bool>
|
||||
IHandler<CreateEventArgs<Wallet<(string, string)>>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(CreateEventArgs<Locker<(string, string)>> args,
|
||||
public async Task<bool> Handle(CreateEventArgs<Wallet<(string, string)>> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is Locker <(string, string)> locker)
|
||||
if (args.Value is Wallet <(string, string)> Wallet)
|
||||
{
|
||||
if (locker.Value is (string name, string password) &&
|
||||
if (Wallet.Value is (string name, string password) &&
|
||||
name is { Length: > 0 } &&
|
||||
password is { Length: > 0 })
|
||||
{
|
||||
@@ -22,16 +22,16 @@ public class CreateLockerHandler(ILockerFactory componentFactory,
|
||||
{
|
||||
ISecurityKeyFactory keyVaultFactory = host.Services.GetRequiredService<ISecurityKeyFactory>();
|
||||
IDecoratorService<SecurityKey> secureKeyStore = host.Services.GetRequiredService<IDecoratorService<SecurityKey>>();
|
||||
ILockerStorageFactory lockerStorageFactory = host.Services.GetRequiredService<ILockerStorageFactory>();
|
||||
IWalletStorageFactory WalletStorageFactory = host.Services.GetRequiredService<IWalletStorageFactory>();
|
||||
|
||||
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password)) is SecurityKey key)
|
||||
{
|
||||
secureKeyStore.Set(key);
|
||||
|
||||
if (await lockerStorageFactory.Create(name, key))
|
||||
if (await WalletStorageFactory.Create(name, key))
|
||||
{
|
||||
IWritableConfiguration<LockerConfiguration> configuration =
|
||||
host.Services.GetRequiredService<IWritableConfiguration<LockerConfiguration>>();
|
||||
IWritableConfiguration<WalletConfiguration> configuration =
|
||||
host.Services.GetRequiredService<IWritableConfiguration<WalletConfiguration>>();
|
||||
|
||||
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 CreateLockerNavigationViewModel(IServiceProvider provider,
|
||||
public partial class CreateWalletNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class CreateLockerViewModel(IServiceProvider provider,
|
||||
public partial class CreateWalletViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IPublisher publisher,
|
||||
IMediator mediator,
|
||||
@@ -22,5 +22,5 @@ public partial class CreateLockerViewModel(IServiceProvider provider,
|
||||
private string password;
|
||||
|
||||
public async Task<bool> Confirm() =>
|
||||
await Mediator.Handle<CreateEventArgs<Locker<(string, string)>>, bool>(Create.As(new Locker<(string, string)>((Name, Password))));
|
||||
await Mediator.Handle<CreateEventArgs<Wallet<(string, string)>>, bool>(Create.As(new Wallet<(string, string)>((Name, Password))));
|
||||
}
|
||||
+7
-7
@@ -4,10 +4,10 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class FilterLockerNavigationViewModel : Observable,
|
||||
ILockerNavigationViewModel,
|
||||
INotificationHandler<ActivatedEventArgs<Locker>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Locker>>
|
||||
public partial class FilterWalletNavigationViewModel : Observable,
|
||||
IWalletNavigationViewModel,
|
||||
INotificationHandler<ActivatedEventArgs<Wallet>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Wallet>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool activated;
|
||||
@@ -18,7 +18,7 @@ public partial class FilterLockerNavigationViewModel : Observable,
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
public FilterLockerNavigationViewModel(IServiceProvider provider,
|
||||
public FilterWalletNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -29,10 +29,10 @@ public partial class FilterLockerNavigationViewModel : Observable,
|
||||
Filter = filter;
|
||||
}
|
||||
|
||||
public Task Handle(DeactivatedEventArgs<Locker> args) =>
|
||||
public Task Handle(DeactivatedEventArgs<Wallet> args) =>
|
||||
Task.FromResult(Activated = false);
|
||||
|
||||
public Task Handle(ActivatedEventArgs<Locker> args) =>
|
||||
public Task Handle(ActivatedEventArgs<Wallet> args) =>
|
||||
Task.FromResult(Activated = true);
|
||||
|
||||
[RelayCommand]
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface ILockerComponent : IComponent;
|
||||
public interface IWalletComponent : IComponent;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault
|
||||
{
|
||||
public interface ILockerFactory
|
||||
public interface IWalletFactory
|
||||
{
|
||||
IComponentHost? Create(string name);
|
||||
}
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface ILockerHost : IComponentHost;
|
||||
public interface IWalletHost : IComponentHost;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface ILockerHostCollection :
|
||||
public interface IWalletHostCollection :
|
||||
IEnumerable<IComponentHost>
|
||||
{
|
||||
void Add(IComponentHost host);
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface ILockerNavigationViewModel :
|
||||
public interface IWalletNavigationViewModel :
|
||||
ISelectable,
|
||||
IDisposable;
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public interface ILockerStorageFactory
|
||||
public interface IWalletStorageFactory
|
||||
{
|
||||
Task<bool> Create(string name, SecurityKey key);
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
||||
|
||||
public override Task OnActivated()
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<LockerCommandHeaderCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<WalletCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<BackActionViewModel>(),
|
||||
})));
|
||||
|
||||
@@ -16,7 +16,7 @@ public partial class ItemCollectionViewModel :
|
||||
[ObservableProperty]
|
||||
public string? named;
|
||||
|
||||
private LockerViewModelConfiguration configuration;
|
||||
private WalletViewModelConfiguration configuration;
|
||||
|
||||
public ItemCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
@@ -26,7 +26,7 @@ public partial class ItemCollectionViewModel :
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
NamedComponent named,
|
||||
LockerViewModelConfiguration configuration,
|
||||
WalletViewModelConfiguration configuration,
|
||||
string? filter = null) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
@@ -61,15 +61,15 @@ public partial class ItemCollectionViewModel :
|
||||
|
||||
public override Task OnActivated()
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<LockerCommandHeaderCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<WalletCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<CreateItemActionViewModel>(),
|
||||
Factory.Create<SearchLockerActionViewModel>(),
|
||||
Factory.Create<SearchWalletActionViewModel>(),
|
||||
})));
|
||||
|
||||
return base.OnActivated();
|
||||
}
|
||||
|
||||
protected override SynchronizeExpression BuildAggregateExpression() =>
|
||||
new(Synchronize.As<ItemNavigationViewModel, LockerViewModelConfiguration>(configuration));
|
||||
new(Synchronize.As<ItemNavigationViewModel, WalletViewModelConfiguration>(configuration));
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record Locker<TValue>(TValue Value);
|
||||
|
||||
public record Locker;
|
||||
@@ -1,35 +0,0 @@
|
||||
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.Services.GetRequiredService<IConfigurationDescriptor<LockerConfiguration>>() is
|
||||
IConfigurationDescriptor<LockerConfiguration> descriptor ? descriptor.Name : null)];
|
||||
|
||||
int index = sortedLockers.IndexOf(locker);
|
||||
|
||||
if (locker.Services.GetRequiredService<ConfigurationDescriptor<LockerConfiguration>>() is ConfigurationDescriptor<LockerConfiguration> descriptor)
|
||||
{
|
||||
if (locker.Services.GetRequiredService<IServiceFactory>() is IServiceFactory serviceFactory)
|
||||
{
|
||||
if (serviceFactory.Create<LockerNavigationViewModel>(descriptor.Name) is LockerNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(new InsertEventArgs<IMainNavigationViewModel>(index, viewModel),
|
||||
nameof(MainViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerComponent(IComponentBuilder builder) : Component(builder),
|
||||
ILockerComponent;
|
||||
@@ -1,17 +0,0 @@
|
||||
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()) is IComponentHost host)
|
||||
{
|
||||
return host;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public partial class ManageViewModel :
|
||||
{
|
||||
Template = template;
|
||||
|
||||
Add<CreateLockerNavigationViewModel>();
|
||||
Add<CreateWalletNavigationViewModel>();
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
@@ -3,19 +3,19 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class OpenLockerHandler(IConfigurationDescriptor<LockerConfiguration> descriptor,
|
||||
public class OpenWalletHandler(IConfigurationDescriptor<WalletConfiguration> descriptor,
|
||||
ISecurityKeyFactory securityKeyFactory,
|
||||
ILockerStorageFactory lockerStorageFactory) :
|
||||
IHandler<ActivateEventArgs<Locker<string>>, bool>
|
||||
IWalletStorageFactory WalletStorageFactory) :
|
||||
IHandler<ActivateEventArgs<Wallet<string>>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(ActivateEventArgs<Locker<string>> args,
|
||||
public async Task<bool> Handle(ActivateEventArgs<Wallet<string>> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is Locker<string> locker &&
|
||||
if (args.Value is Wallet<string> Wallet &&
|
||||
descriptor.Name is { Length: > 0 } name &&
|
||||
locker.Value is { Length: > 0 } password)
|
||||
Wallet.Value is { Length: > 0 } password)
|
||||
{
|
||||
LockerConfiguration configuration = descriptor.Value;
|
||||
WalletConfiguration configuration = descriptor.Value;
|
||||
if (configuration.Key?.Split(':') is { Length: >= 2 } keyPart)
|
||||
{
|
||||
byte[]? salt = Convert.FromBase64String(keyPart[0]);
|
||||
@@ -23,7 +23,7 @@ public class OpenLockerHandler(IConfigurationDescriptor<LockerConfiguration> des
|
||||
|
||||
if (securityKeyFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
|
||||
{
|
||||
if (await lockerStorageFactory.Create(name, key))
|
||||
if (await WalletStorageFactory.Create(name, key))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class OpenLockerViewModel(IServiceProvider provider,
|
||||
public partial class OpenWalletViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -24,9 +24,9 @@ public partial class OpenLockerViewModel(IServiceProvider provider,
|
||||
{
|
||||
if (Password is { Length: > 0 })
|
||||
{
|
||||
if (await Mediator.Handle<ActivateEventArgs<Locker<string>>, bool>(Activate.As(new Locker<string>(Password))))
|
||||
if (await Mediator.Handle<ActivateEventArgs<Wallet<string>>, bool>(Activate.As(new Wallet<string>(Password))))
|
||||
{
|
||||
Publisher.Publish(Opened.As<Locker>());
|
||||
Publisher.Publish(Opened.As<Wallet>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,16 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class QueryLockerHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IHandler<QueryEventArgs<Locker<(string, string)>>, IReadOnlyCollection<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)>>
|
||||
public class QueryWalletHandler(IDbContextFactory<WalletContext> dbContextFactory) :
|
||||
IHandler<QueryEventArgs<Wallet<(string, string)>>, IReadOnlyCollection<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)>>
|
||||
{
|
||||
public async Task<IReadOnlyCollection<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)>>
|
||||
Handle(QueryEventArgs<Locker<(string, string)>> args,CancellationToken cancellationToken)
|
||||
Handle(QueryEventArgs<Wallet<(string, string)>> args,CancellationToken cancellationToken)
|
||||
{
|
||||
List<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)> items = [];
|
||||
if (args.Value is Locker<(string, string)> locker)
|
||||
if (args.Value is Wallet<(string, string)> Wallet)
|
||||
{
|
||||
(string filter, string text) = locker.Value;
|
||||
(string filter, string text) = Wallet.Value;
|
||||
|
||||
ExpressionStarter<ItemEntry> predicate =
|
||||
PredicateBuilder.New<ItemEntry>(true);
|
||||
@@ -39,7 +39,7 @@ public class QueryLockerHandler(IDbContextFactory<LockerContext> dbContextFactor
|
||||
predicate = predicate.And(x => EF.Functions.Like(x.Name, $"%{text}%"));
|
||||
}
|
||||
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
using WalletContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
var results = await context.Set<ItemEntry>()
|
||||
.Where(predicate)
|
||||
.Select(x => new
|
||||
@@ -5,7 +5,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class RequestItemHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
public class RequestItemHandler(IDbContextFactory<WalletContext> dbContextFactory) :
|
||||
IHandler<RequestEventArgs<Item<Guid>>, (Guid, string, string?, string, ItemConfiguration?)>
|
||||
{
|
||||
public async Task<(Guid, string, string?, string, ItemConfiguration?)> Handle(RequestEventArgs<Item<Guid>> args,
|
||||
@@ -15,7 +15,7 @@ public class RequestItemHandler(IDbContextFactory<LockerContext> dbContextFactor
|
||||
{
|
||||
Guid id = item.Value;
|
||||
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
using WalletContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
var result = await context.Set<ItemEntry>()
|
||||
.Where(x => x.Id == id)
|
||||
.Select(x => new
|
||||
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class SearchLockerActionViewModel(IServiceProvider provider,
|
||||
public partial class SearchWalletActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -8,4 +8,4 @@ public partial class StarredNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterWalletNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -7,19 +7,19 @@ public class SynchronizeItemViewModelHandler(IMediator mediator,
|
||||
IServiceProvider serviceProvider,
|
||||
ICache<Item<(Guid, string)>> cache,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<SynchronizeEventArgs<ItemNavigationViewModel, LockerViewModelConfiguration>>
|
||||
INotificationHandler<SynchronizeEventArgs<ItemNavigationViewModel, WalletViewModelConfiguration>>
|
||||
{
|
||||
public async Task Handle(SynchronizeEventArgs<ItemNavigationViewModel,
|
||||
LockerViewModelConfiguration> args)
|
||||
WalletViewModelConfiguration> args)
|
||||
{
|
||||
if (args.Value is LockerViewModelConfiguration configuration)
|
||||
if (args.Value is WalletViewModelConfiguration configuration)
|
||||
{
|
||||
cache.Clear();
|
||||
bool selected = true;
|
||||
|
||||
IReadOnlyCollection<(Guid Id, string Name, string Category, bool Favourite, bool Archived)>? results =
|
||||
await mediator.Handle<QueryEventArgs<Locker<(string?, string?)>>,
|
||||
IReadOnlyCollection<(Guid Id, string Name, string Category, bool Favourite, bool Archived)>>(Query.As(new Locker<(string?, string?)>((configuration.Filter, configuration.Query))));
|
||||
await mediator.Handle<QueryEventArgs<Wallet<(string?, string?)>>,
|
||||
IReadOnlyCollection<(Guid Id, string Name, string Category, bool Favourite, bool Archived)>>(Query.As(new Wallet<(string?, string?)>((configuration.Filter, configuration.Query))));
|
||||
|
||||
if (results is not null)
|
||||
{
|
||||
|
||||
@@ -4,22 +4,22 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
public class SynchronizeMainViewModelHandler(IPublisher publisher,
|
||||
ILockerHostCollection lockers) :
|
||||
IWalletHostCollection Wallets) :
|
||||
INotificationHandler<SynchronizeEventArgs<IMainNavigationViewModel>>
|
||||
{
|
||||
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))
|
||||
foreach (IComponentHost Wallet in Wallets.OrderBy(x => x.Services.GetRequiredService<IConfigurationDescriptor<WalletConfiguration>>()
|
||||
is IConfigurationDescriptor<WalletConfiguration> descriptor ? descriptor.Name : null))
|
||||
{
|
||||
if (locker.Services.GetRequiredService<IConfigurationDescriptor<LockerConfiguration>>()
|
||||
is IConfigurationDescriptor<LockerConfiguration> descriptor)
|
||||
if (Wallet.Services.GetRequiredService<IConfigurationDescriptor<WalletConfiguration>>()
|
||||
is IConfigurationDescriptor<WalletConfiguration> descriptor)
|
||||
{
|
||||
if (locker.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||
if (Wallet.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||
{
|
||||
if (factory.Create<LockerNavigationViewModel>(descriptor.Name, selected)
|
||||
is LockerNavigationViewModel viewModel)
|
||||
if (factory.Create<WalletNavigationViewModel>(descriptor.Name, selected)
|
||||
is WalletNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(Create.As<IMainNavigationViewModel>(viewModel),
|
||||
nameof(MainViewModel));
|
||||
|
||||
@@ -6,7 +6,7 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
public class UnarchiveItemHandler(IDecoratorService<Item<(Guid, string)>> decoratorService,
|
||||
IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IDbContextFactory<WalletContext> dbContextFactory) :
|
||||
INotificationHandler<UnarchiveEventArgs<Item>>
|
||||
{
|
||||
public async Task Handle(UnarchiveEventArgs<Item> args)
|
||||
@@ -17,7 +17,7 @@ public class UnarchiveItemHandler(IDecoratorService<Item<(Guid, string)>> decora
|
||||
{
|
||||
(Guid id, string name) = item.Value;
|
||||
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
using WalletContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
if (await context.FindAsync<ItemEntry>(id) is ItemEntry result)
|
||||
{
|
||||
result.State = 0;
|
||||
|
||||
@@ -6,7 +6,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class UpdateItemHander(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
public class UpdateItemHander(IDbContextFactory<WalletContext> dbContextFactory) :
|
||||
IHandler<UpdateEventArgs<Item<(Guid, string, ItemConfiguration)>>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(UpdateEventArgs<Item<(Guid, string, ItemConfiguration)>> args,
|
||||
@@ -18,7 +18,7 @@ public class UpdateItemHander(IDbContextFactory<LockerContext> dbContextFactory)
|
||||
|
||||
try
|
||||
{
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
using WalletContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
ItemEntry? result = result = await context.Set<ItemEntry>().FindAsync([id], cancellationToken);
|
||||
|
||||
if (result is not null)
|
||||
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class UpdateItemStateHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
public class UpdateItemStateHandler(IDbContextFactory<WalletContext> dbContextFactory) :
|
||||
IHandler<UpdateEventArgs<(Guid, int)>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(UpdateEventArgs<(Guid, int)> args,
|
||||
@@ -14,7 +14,7 @@ public class UpdateItemStateHandler(IDbContextFactory<LockerContext> dbContextFa
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
using WalletContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
if (await context.FindAsync<ItemEntry>(id) is ItemEntry result)
|
||||
{
|
||||
result.State = state;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record Wallet<TValue>(TValue Value);
|
||||
|
||||
public record Wallet;
|
||||
@@ -0,0 +1,35 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class WalletActivatedHandler(IWalletHostCollection Wallets,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ActivatedEventArgs<IComponentHost>>
|
||||
{
|
||||
public Task Handle(ActivatedEventArgs<IComponentHost> args)
|
||||
{
|
||||
if (args.Value is IComponentHost Wallet)
|
||||
{
|
||||
List<IComponentHost> sortedWallets = [.. Wallets, Wallet];
|
||||
sortedWallets = [.. sortedWallets.OrderBy(x => x.Services.GetRequiredService<IConfigurationDescriptor<WalletConfiguration>>() is
|
||||
IConfigurationDescriptor<WalletConfiguration> descriptor ? descriptor.Name : null)];
|
||||
|
||||
int index = sortedWallets.IndexOf(Wallet);
|
||||
|
||||
if (Wallet.Services.GetRequiredService<ConfigurationDescriptor<WalletConfiguration>>() is ConfigurationDescriptor<WalletConfiguration> descriptor)
|
||||
{
|
||||
if (Wallet.Services.GetRequiredService<IServiceFactory>() is IServiceFactory serviceFactory)
|
||||
{
|
||||
if (serviceFactory.Create<WalletNavigationViewModel>(descriptor.Name) is WalletNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(new InsertEventArgs<IMainNavigationViewModel>(index, viewModel),
|
||||
nameof(MainViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,5 +2,5 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerCommandHeaderCollection(IList<IDisposable> list) :
|
||||
public class WalletCommandHeaderCollection(IList<IDisposable> list) :
|
||||
ReadOnlyCollection<IDisposable>(list);
|
||||
@@ -0,0 +1,6 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class WalletComponent(IComponentBuilder builder) : Component(builder),
|
||||
IWalletComponent;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record LockerConfiguration :
|
||||
public record WalletConfiguration :
|
||||
ComponentConfiguration
|
||||
{
|
||||
public string? Key { get; set; }
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerConnection(string connection)
|
||||
public class WalletConnection(string connection)
|
||||
{
|
||||
private readonly string connection = connection;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class WalletFactory(IComponentFactory componentFactory) :
|
||||
IWalletFactory
|
||||
{
|
||||
public IComponentHost? Create(string name)
|
||||
{
|
||||
if (componentFactory.Create<IWalletComponent, WalletConfiguration>($"Wallet:{name}", new WalletConfiguration()) is IComponentHost host)
|
||||
{
|
||||
return host;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class LockerHeaderViewModel(IServiceProvider provider,
|
||||
public partial class WalletHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -10,15 +10,15 @@ public partial class LockerHeaderViewModel(IServiceProvider provider,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<NotifyEventArgs<LockerCommandHeaderCollection>>
|
||||
INotificationHandler<NotifyEventArgs<WalletCommandHeaderCollection>>
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(NotifyEventArgs<LockerCommandHeaderCollection> args)
|
||||
public Task Handle(NotifyEventArgs<WalletCommandHeaderCollection> args)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (args.Value is LockerCommandHeaderCollection commandCollection)
|
||||
if (args.Value is WalletCommandHeaderCollection commandCollection)
|
||||
{
|
||||
foreach (IDisposable command in commandCollection)
|
||||
{
|
||||
@@ -3,8 +3,8 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerHostCollection :
|
||||
ILockerHostCollection
|
||||
public class WalletHostCollection :
|
||||
IWalletHostCollection
|
||||
|
||||
{
|
||||
private readonly List<IComponentHost> hosts = [];
|
||||
@@ -0,0 +1,22 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class WalletInitializer(IEnumerable<IConfigurationDescriptor<WalletConfiguration>> configurations,
|
||||
IComponentFactory componentFactory,
|
||||
IWalletHostCollection Wallets) : IInitializer
|
||||
{
|
||||
public async Task Initialize()
|
||||
{
|
||||
foreach (IConfigurationDescriptor<WalletConfiguration> configuration in configurations)
|
||||
{
|
||||
if (componentFactory.Create<IWalletComponent,
|
||||
WalletConfiguration>(configuration.Section, configuration.Value)
|
||||
is IComponentHost host)
|
||||
{
|
||||
Wallets.Add(host);
|
||||
await host.StartAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class LockerNavigationViewModel :
|
||||
ObservableCollection<ILockerNavigationViewModel>,
|
||||
public partial class WalletNavigationViewModel :
|
||||
ObservableCollection<IWalletNavigationViewModel>,
|
||||
IMainNavigationViewModel,
|
||||
INotificationHandler<OpenedEventArgs<Locker>>,
|
||||
INotificationHandler<ClosedEventArgs<Locker>>,
|
||||
INotificationHandler<ActivatedEventArgs<Locker>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Locker>>,
|
||||
INotificationHandler<OpenedEventArgs<Wallet>>,
|
||||
INotificationHandler<ClosedEventArgs<Wallet>>,
|
||||
INotificationHandler<ActivatedEventArgs<Wallet>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Wallet>>,
|
||||
ISelectable
|
||||
{
|
||||
[ObservableProperty]
|
||||
@@ -27,7 +27,7 @@ public partial class LockerNavigationViewModel :
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
public LockerNavigationViewModel(IServiceProvider provider,
|
||||
public WalletNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -44,7 +44,7 @@ public partial class LockerNavigationViewModel :
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
public Task Handle(OpenedEventArgs<Locker> args)
|
||||
public Task Handle(OpenedEventArgs<Wallet> args)
|
||||
{
|
||||
Add<AllNavigationViewModel>("All");
|
||||
Add<StarredNavigationViewModel>("Starred");
|
||||
@@ -55,7 +55,7 @@ public partial class LockerNavigationViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(ClosedEventArgs<Locker> args)
|
||||
public Task Handle(ClosedEventArgs<Wallet> args)
|
||||
{
|
||||
Opened = true;
|
||||
Clear();
|
||||
@@ -63,9 +63,9 @@ public partial class LockerNavigationViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(DeactivatedEventArgs<Locker> args) =>
|
||||
public Task Handle(DeactivatedEventArgs<Wallet> args) =>
|
||||
Task.FromResult(Activated = false);
|
||||
|
||||
public Task Handle(ActivatedEventArgs<Locker> args) =>
|
||||
public Task Handle(ActivatedEventArgs<Wallet> args) =>
|
||||
Task.FromResult(Activated = true);
|
||||
}
|
||||
@@ -6,19 +6,19 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerStorageFactory(IDecoratorService<LockerConnection> connection,
|
||||
public class WalletStorageFactory(IDecoratorService<WalletConnection> connection,
|
||||
IHostEnvironment environment,
|
||||
IServiceProvider provider) :
|
||||
ILockerStorageFactory
|
||||
IWalletStorageFactory
|
||||
{
|
||||
public async Task<bool> Create(string name,
|
||||
SecurityKey key)
|
||||
{
|
||||
connection.Set(new LockerConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||
connection.Set(new WalletConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||
$".vault;Mode=ReadWriteCreate;Pooling=true;Password={Convert.ToBase64String(key.DecryptedKey)}"));
|
||||
|
||||
IDbContextFactory<LockerContext> dbContextFactory = provider.GetRequiredService<IDbContextFactory<LockerContext>>();
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
IDbContextFactory<WalletContext> dbContextFactory = provider.GetRequiredService<IDbContextFactory<WalletContext>>();
|
||||
using WalletContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class LockerViewModel :
|
||||
public partial class WalletViewModel :
|
||||
Observable
|
||||
{
|
||||
[ObservableProperty]
|
||||
@@ -11,7 +11,7 @@ public partial class LockerViewModel :
|
||||
|
||||
[ObservableProperty]
|
||||
private string filter;
|
||||
public LockerViewModel(IServiceProvider provider,
|
||||
public WalletViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -26,13 +26,13 @@ public partial class LockerViewModel :
|
||||
|
||||
public override async Task OnActivated()
|
||||
{
|
||||
Publisher.Publish(Activated.As<Locker>());
|
||||
Publisher.Publish(Activated.As<Wallet>());
|
||||
await base.OnActivated();
|
||||
}
|
||||
|
||||
public override async Task OnDeactivated()
|
||||
{
|
||||
Publisher.Publish(Deactivated.As<Locker>());
|
||||
Publisher.Publish(Deactivated.As<Wallet>());
|
||||
await base.OnDeactivated();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record LockerViewModelConfiguration
|
||||
public record WalletViewModelConfiguration
|
||||
{
|
||||
public string? Filter { get; set; } = "All";
|
||||
|
||||
Reference in New Issue
Block a user