Worlds fastest rename

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