Mass rename to align planned codename
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="Container">
|
||||
<NavigateAction Region="Main" Route="Locker">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
|
||||
@@ -9,6 +9,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Toolkit.Avalonia;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
@@ -25,16 +26,16 @@ public partial class App : Application
|
||||
public override async void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
IHost? host = DefaultHostBuilder.Create()
|
||||
.AddConfiguration<ContainerConfiguration>("Locker:*")
|
||||
.AddConfiguration<LockerConfiguration>("Locker:*")
|
||||
.AddConfiguration<ItemConfiguration>("Item:*")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Bank Account", "Item:Bank Account")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Credit Card", "Item:Credit Card")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Document", "Item:Document")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Driving Licence", "Item:Driving Licence")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Identity", "Item:Identity")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Login", "Item:Login")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Note", "Item:Note")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Password", "Item:Password")
|
||||
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Bank Account", "Item:Bank Account")
|
||||
.AddConfiguration("Item:Credit Card", ItemConfiguration.CreditCard)
|
||||
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Document", "Item:Document")
|
||||
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Driving Licence", "Item:Driving Licence")
|
||||
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Identity", "Item:Identity")
|
||||
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Login", "Item:Login")
|
||||
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Note", "Item:Note")
|
||||
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Password", "Item:Password")
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddAvalonia();
|
||||
@@ -48,9 +49,9 @@ public partial class App : Application
|
||||
services.AddScoped<IProxyService<IEnumerable<ItemConfiguration>>>(provider =>
|
||||
new ProxyService<IEnumerable<ItemConfiguration>>(provider.GetRequiredService<IEnumerable<ItemConfiguration>>()));
|
||||
|
||||
services.AddHandler<ContainerActivatedHandler>();
|
||||
services.AddHandler<LockerActivatedHandler>();
|
||||
|
||||
services.AddTransient<IContainerComponent>(provider => Component.Create<ContainerComponent>(provider, args =>
|
||||
services.AddTransient<ILockerComponent>(provider => Component.Create<LockerComponent>(provider, args =>
|
||||
{
|
||||
args.AddServices(services =>
|
||||
{
|
||||
@@ -70,48 +71,48 @@ public partial class App : Application
|
||||
services.AddTransient<IKeyDeriver, KeyDeriver>();
|
||||
|
||||
services.AddTransient<ISecurityKeyFactory, SecurityKeyFactory>();
|
||||
services.AddTransient<IContainerStorageFactory, ContainerStorageFactory>();
|
||||
services.AddTransient<ILockerStorageFactory, LockerStorageFactory>();
|
||||
services.TryAddSingleton<IValueStore<SecurityKey>, ValueStore<SecurityKey>>();
|
||||
services.TryAddSingleton<IValueStore<ContainerConnection>, ValueStore<ContainerConnection>>();
|
||||
services.TryAddSingleton<IValueStore<LockerConnection>, ValueStore<LockerConnection>>();
|
||||
|
||||
services.AddDbContextFactory<ContainerDbContext>((provider, args) =>
|
||||
services.AddDbContextFactory<LockerContext>((provider, args) =>
|
||||
{
|
||||
if (provider.GetRequiredService<IValueStore<ContainerConnection>>()
|
||||
is IValueStore<ContainerConnection> connection)
|
||||
if (provider.GetRequiredService<IValueStore<LockerConnection>>()
|
||||
is IValueStore<LockerConnection> connection)
|
||||
{
|
||||
args.UseSqlite($"{connection.Value}");
|
||||
}
|
||||
});
|
||||
|
||||
services.AddHandler<QueryContainerHandler>();
|
||||
services.AddHandler<QueryLockerHandler>();
|
||||
services.AddHandler<CreateItemHandler>();
|
||||
services.AddHandler<UpdateItemHander>();
|
||||
services.AddHandler<UpdateItemStateHandler>();
|
||||
|
||||
services.AddHandler<OpenContainerHandler>();
|
||||
services.AddHandler<OpenLockerHandler>();
|
||||
|
||||
services.AddTemplate<ContainerNavigationViewModel, ContainerNavigationView>();
|
||||
services.AddTemplate<LockerNavigationViewModel, LockerNavigationView>();
|
||||
services.AddTemplate<AllNavigationViewModel, AllNavigationView>();
|
||||
services.AddTemplate<StarredNavigationViewModel, StarredNavigationView>();
|
||||
services.AddTemplate<CategoriesNavigationViewModel, CategoriesNavigationView>();
|
||||
services.AddTemplate<ArchiveNavigationViewModel, ArchiveNavigationView>();
|
||||
|
||||
services.AddTemplate<OpenContainerViewModel, OpenView>("OpenContainer");
|
||||
services.AddTemplate<OpenLockerViewModel, OpenView>("OpenLocker");
|
||||
|
||||
services.AddScoped<ContainerViewModelConfiguration>();
|
||||
services.AddScoped<LockerViewModelConfiguration>();
|
||||
|
||||
services.AddTemplate<ContainerViewModel, ContainerView>("Container");
|
||||
services.AddTemplate<LockerViewModel, LockerView>("Locker");
|
||||
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
||||
services.AddHandler<AggerateContainerItemViewModelHandler>();
|
||||
services.AddHandler<AggerateLockerItemViewModelHandler>();
|
||||
|
||||
services.AddTemplate<SearchContainerActionViewModel, SearchContainerActionView>();
|
||||
services.AddTemplate<ContainerHeaderViewModel, ContainerHeaderView>("ContainerHeader");
|
||||
services.AddTemplate<SearchLockerActionViewModel, SearchLockerActionView>();
|
||||
services.AddTemplate<LockerHeaderViewModel, LockerHeaderView>("LockerHeader");
|
||||
|
||||
services.AddTemplate<CreateItemActionViewModel, CreateItemActionView>();
|
||||
services.AddTemplate<ItemCategoryCollectionViewModel, ItemCategoryCollectionView>("ContainerItemCategoryCollection");
|
||||
services.AddTemplate<ItemCategoryCollectionViewModel, ItemCategoryCollectionView>("LockerItemCategoryCollection");
|
||||
services.AddTemplate<ItemCategoryNavigationViewModel, ItemCategoryNavigationView>();
|
||||
|
||||
services.AddHandler<AggerateContainerCategoryViewModelHandler>();
|
||||
services.AddHandler<AggerateLockerCategoryViewModelHandler>();
|
||||
|
||||
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
||||
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
||||
@@ -144,11 +145,11 @@ public partial class App : Application
|
||||
});
|
||||
})!);
|
||||
|
||||
services.AddTransient<IContainerFactory, ContainerFactory>();
|
||||
services.AddHandler<CreateContainerHandler>();
|
||||
services.AddTransient<ILockerFactory, LockerFactory>();
|
||||
services.AddHandler<CreateLockerHandler>();
|
||||
|
||||
services.AddSingleton<IContainerHostCollection, ContainerHostCollection>();
|
||||
services.AddInitializer<ContainerInitializer>();
|
||||
services.AddSingleton<ILockerHostCollection, LockerHostCollection>();
|
||||
services.AddInitializer<LockerInitializer>();
|
||||
|
||||
services.AddTemplate<MainViewModel, MainView>("Main");
|
||||
services.AddHandler<AggerateMainViewModelHandler>();
|
||||
@@ -158,8 +159,8 @@ public partial class App : Application
|
||||
services.AddTemplate<ManageNavigationViewModel, ManageNavigationView>();
|
||||
services.AddTemplate<ManageViewModel, ManageView>("Manage");
|
||||
|
||||
services.AddTemplate<CreateContainerNavigationViewModel, CreateContainerNavigationView>();
|
||||
services.AddTemplate<CreateContainerViewModel, CreateContainerView>("CreateContainer");
|
||||
services.AddTemplate<CreateLockerNavigationViewModel, CreateLockerNavigationView>();
|
||||
services.AddTemplate<CreateLockerViewModel, CreateLockerView>("CreateLocker");
|
||||
})
|
||||
.Build();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="Container">
|
||||
<NavigateAction Region="Main" Route="Locker">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
|
||||
@@ -61,11 +61,11 @@
|
||||
<Compile Update="ConfirmItemActionView.axaml.cs">
|
||||
<DependentUpon>ConfirmItemActionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="CreateContainerNavigationView.axaml.cs">
|
||||
<DependentUpon>CreateContainerNavigationView.axaml</DependentUpon>
|
||||
<Compile Update="CreateLockerNavigationView.axaml.cs">
|
||||
<DependentUpon>CreateLockerNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="CreateContainerView.axaml.cs">
|
||||
<DependentUpon>CreateContainerView.axaml</DependentUpon>
|
||||
<Compile Update="CreateLockerView.axaml.cs">
|
||||
<DependentUpon>CreateLockerView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="DismissItemActionView.axaml.cs">
|
||||
<DependentUpon>DismissItemActionView.axaml</DependentUpon>
|
||||
@@ -82,8 +82,8 @@
|
||||
<Compile Update="ManageNavigationView.axaml.cs">
|
||||
<DependentUpon>ManageNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ContainerHeaderView.axaml.cs">
|
||||
<DependentUpon>ContainerHeaderView.axaml</DependentUpon>
|
||||
<Compile Update="LockerHeaderView.axaml.cs">
|
||||
<DependentUpon>LockerHeaderView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ItemNavigationView.axaml.cs">
|
||||
<DependentUpon>ItemNavigationView.axaml</DependentUpon>
|
||||
@@ -91,11 +91,14 @@
|
||||
<Compile Update="ItemView.axaml.cs">
|
||||
<DependentUpon>ItemView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ContainerNavigationView.axaml.cs">
|
||||
<DependentUpon>ContainerNavigationView.axaml</DependentUpon>
|
||||
<Compile Update="LockerNavigationView.axaml.cs">
|
||||
<DependentUpon>LockerNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ContainerView.axaml.cs">
|
||||
<DependentUpon>ContainerView.axaml</DependentUpon>
|
||||
<Compile Update="LockerView.axaml.cs">
|
||||
<DependentUpon>LockerView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="SearchLockerActionView.axaml.cs">
|
||||
<DependentUpon>SearchLockerActionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ContainerHeaderView : UserControl
|
||||
{
|
||||
public ContainerHeaderView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ContainerNavigationView : NavigationViewItem
|
||||
{
|
||||
public ContainerNavigationView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateContainerNavigationView : SettingsExpander
|
||||
{
|
||||
public CreateContainerNavigationView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateContainerView : ContentDialog
|
||||
{
|
||||
public CreateContainerView() => InitializeComponent();
|
||||
}
|
||||
@@ -28,9 +28,9 @@
|
||||
</Grid>
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Click">
|
||||
<NavigateAction Region="Left" Route="ContainerItemCategoryCollection">
|
||||
<Parameter Key="Transition" Value="FromRight" />
|
||||
</NavigateAction>
|
||||
<NavigateAction Region="Left" Route="LockerItemCategoryCollection">
|
||||
<Parameter Key="Transition" Value="FromRight" />
|
||||
</NavigateAction>
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Button>
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
<SettingsExpander
|
||||
x:Class="Bitvault.Avalonia.CreateContainerNavigationView"
|
||||
x:Class="Bitvault.Avalonia.CreateLockerNavigationView"
|
||||
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="CreateContainer" />
|
||||
<NavigateAction Region="self" Route="CreateLocker" />
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Button>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateLockerNavigationView : SettingsExpander
|
||||
{
|
||||
public CreateLockerNavigationView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<ContentDialog
|
||||
x:Class="Bitvault.Avalonia.CreateContainerView"
|
||||
x:Class="Bitvault.Avalonia.CreateLockerView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
Title="Create vault"
|
||||
x:DataType="vm:CreateContainerViewModel"
|
||||
x:DataType="vm:CreateLockerViewModel"
|
||||
CloseButtonText="Cancel"
|
||||
PrimaryButtonText="Create">
|
||||
<StackPanel Width="400">
|
||||
@@ -0,0 +1,9 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateLockerView : ContentDialog
|
||||
{
|
||||
public CreateLockerView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.ContainerHeaderView"
|
||||
x:Class="Bitvault.Avalonia.LockerHeaderView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ContainerHeaderViewModel">
|
||||
x:DataType="vm:LockerHeaderViewModel">
|
||||
<ItemsControl ItemTemplate="{ReflectionBinding Template}" ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class LockerHeaderView : UserControl
|
||||
{
|
||||
public LockerHeaderView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
<NavigationViewItem
|
||||
x:Class="Bitvault.Avalonia.ContainerNavigationView"
|
||||
x:Class="Bitvault.Avalonia.LockerNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:Name="NavigationViewItem"
|
||||
x:DataType="vm:ContainerNavigationViewModel"
|
||||
x:DataType="vm:LockerNavigationViewModel"
|
||||
Content="{Binding Name}"
|
||||
IsExpanded="{Binding Expanded}"
|
||||
IsSelected="{Binding Selected}"
|
||||
@@ -19,7 +19,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="OpenContainer" />
|
||||
<NavigateAction Region="Main" Route="OpenLocker" />
|
||||
<ChangePropertyAction
|
||||
PropertyName="SelectsOnInvoked"
|
||||
TargetObject="{Binding #NavigationViewItem}"
|
||||
@@ -47,7 +47,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Opened}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="OpenContainer" />
|
||||
<NavigateAction Region="Main" Route="OpenLocker" />
|
||||
</ConditionAction>
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
@@ -56,7 +56,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="Container" />
|
||||
<NavigateAction Region="Main" Route="Locker" />
|
||||
<InvokeNavigationViewItemAction />
|
||||
</ConditionAction>
|
||||
</AttachedEventTriggerBehaviour>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class LockerNavigationView : NavigationViewItem
|
||||
{
|
||||
public LockerNavigationView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.ContainerView"
|
||||
x:Class="Bitvault.Avalonia.LockerView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ContainerViewModel">
|
||||
x:DataType="vm:LockerViewModel">
|
||||
<Grid
|
||||
x:Name="Container"
|
||||
ColumnDefinitions="320,Auto,*,Auto"
|
||||
@@ -17,7 +17,7 @@
|
||||
<ContentControl VerticalAlignment="Center">
|
||||
<Interaction.Behaviors>
|
||||
<AttachedBehaviour>
|
||||
<NavigateAction Region="{Binding $self}" Route="ContainerHeader" />
|
||||
<NavigateAction Region="{Binding $self}" Route="LockerHeader" />
|
||||
</AttachedBehaviour>
|
||||
</Interaction.Behaviors>
|
||||
</ContentControl>
|
||||
@@ -4,9 +4,9 @@ using FluentAvalonia.UI.Windowing;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ContainerView : UserControl
|
||||
public partial class LockerView : UserControl
|
||||
{
|
||||
public ContainerView() => InitializeComponent();
|
||||
public LockerView() => InitializeComponent();
|
||||
|
||||
protected override void OnLoaded(RoutedEventArgs args)
|
||||
{
|
||||
@@ -16,7 +16,7 @@
|
||||
<Interaction.Behaviors>
|
||||
<AttachedBehaviour>
|
||||
<NavigateRegionAction Name="Main">
|
||||
<NavigateAction Region="Main" Route="Container" />
|
||||
<NavigateAction Region="Main" Route="Locker" />
|
||||
</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 Vaults">
|
||||
Content="Manage Lockers">
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Tapped">
|
||||
<NavigateAction Region="Main" Route="Manage" />
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:OpenContainerViewModel">
|
||||
x:DataType="vm:OpenLockerViewModel">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBox
|
||||
Width="300"
|
||||
@@ -11,9 +11,9 @@
|
||||
PasswordChar="●"
|
||||
Text="{Binding Password}">
|
||||
<Interaction.Behaviors>
|
||||
<KeyBindingTriggerBehaviour Gesture="Enter">
|
||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||
</KeyBindingTriggerBehaviour>
|
||||
<KeyBindingTriggerBehaviour Gesture="Enter">
|
||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||
</KeyBindingTriggerBehaviour>
|
||||
</Interaction.Behaviors>
|
||||
</TextBox>
|
||||
</StackPanel>
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class SearchContainerActionView : UserControl
|
||||
{
|
||||
public SearchContainerActionView() => InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.SearchContainerActionView"
|
||||
x:Class="Bitvault.Avalonia.SearchLockerActionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:SearchContainerActionViewModel">
|
||||
x:DataType="vm:SearchLockerActionViewModel">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class SearchLockerActionView : UserControl
|
||||
{
|
||||
public SearchLockerActionView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="Container">
|
||||
<NavigateAction Region="Main" Route="Locker">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault.Data;
|
||||
|
||||
public class ContainerDbContext(DbContextOptions<ContainerDbContext> options) :
|
||||
public class LockerContext(DbContextOptions<LockerContext> options) :
|
||||
DbContext(options)
|
||||
{
|
||||
public DbSet<BlobEntry> Blobs { get; set; }
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateContainerCategoryViewModelHandler(IProxyService<IEnumerable<ItemConfiguration>> proxyConfigurations,
|
||||
public class AggerateLockerCategoryViewModelHandler(IProxyService<IEnumerable<ItemConfiguration>> proxyConfigurations,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<ItemCategoryNavigationViewModel>>
|
||||
+6
-6
@@ -3,23 +3,23 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateContainerItemViewModelHandler(IMediator mediator,
|
||||
public class AggerateLockerItemViewModelHandler(IMediator mediator,
|
||||
IServiceProvider serviceProvider,
|
||||
ICache<Item> cache,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel,
|
||||
ContainerViewModelConfiguration>>
|
||||
LockerViewModelConfiguration>>
|
||||
{
|
||||
public async Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
||||
ContainerViewModelConfiguration> args)
|
||||
LockerViewModelConfiguration> args)
|
||||
{
|
||||
if (args.Options is ContainerViewModelConfiguration configuration)
|
||||
if (args.Options is LockerViewModelConfiguration configuration)
|
||||
{
|
||||
cache.Clear();
|
||||
bool selected = true;
|
||||
|
||||
if (await mediator.Handle<RequestEventArgs<QueryContainerConfiguration>,
|
||||
IReadOnlyCollection<(Guid Id, string Name, bool Favourite, bool Archived)>>(Request.As(new QueryContainerConfiguration
|
||||
if (await mediator.Handle<RequestEventArgs<QueryLockerConfiguration>,
|
||||
IReadOnlyCollection<(Guid Id, string Name, bool Favourite, bool Archived)>>(Request.As(new QueryLockerConfiguration
|
||||
{
|
||||
Filter = configuration.Filter,
|
||||
Query = configuration.Query
|
||||
@@ -4,19 +4,19 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateMainViewModelHandler(IPublisher publisher,
|
||||
IContainerHostCollection containers) :
|
||||
ILockerHostCollection lockers) :
|
||||
INotificationHandler<AggerateEventArgs<IMainNavigationViewModel>>
|
||||
{
|
||||
public Task Handle(AggerateEventArgs<IMainNavigationViewModel> args)
|
||||
{
|
||||
foreach (IComponentHost container in containers.OrderBy(x => x.GetConfiguration<ContainerConfiguration>()
|
||||
is ContainerConfiguration configuration ? configuration.Name : null))
|
||||
foreach (IComponentHost locker in lockers.OrderBy(x => x.GetConfiguration<LockerConfiguration>()
|
||||
is LockerConfiguration configuration ? configuration.Name : null))
|
||||
{
|
||||
if (container.Services.GetRequiredService<ContainerConfiguration>() is ContainerConfiguration configuration)
|
||||
if (locker.Services.GetRequiredService<LockerConfiguration>() is LockerConfiguration configuration)
|
||||
{
|
||||
if (container.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||
if (locker.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||
{
|
||||
if (factory.Create<ContainerNavigationViewModel>(configuration.Name) is ContainerNavigationViewModel viewModel)
|
||||
if (factory.Create<LockerNavigationViewModel>(configuration.Name) is LockerNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(Create.As<IMainNavigationViewModel>(viewModel),
|
||||
nameof(MainViewModel));
|
||||
|
||||
@@ -8,4 +8,4 @@ public partial class AllNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string filter) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||
string filter) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||
@@ -8,4 +8,4 @@ public partial class ArchiveNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -8,4 +8,4 @@ public partial class CategoriesNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -1,8 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class CommandCollection(IList<IDisposable> list) :
|
||||
ReadOnlyCollection<IDisposable>(list)
|
||||
{
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerActivatedHandler(IContainerHostCollection containers,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ActivatedEventArgs<IComponentHost>>
|
||||
{
|
||||
public Task Handle(ActivatedEventArgs<IComponentHost> args)
|
||||
{
|
||||
if (args.Value is IComponentHost container)
|
||||
{
|
||||
List<IComponentHost> sortedContainers = [.. containers, container];
|
||||
sortedContainers = [.. sortedContainers.OrderBy(x => x.GetConfiguration<ContainerConfiguration>() is ContainerConfiguration configuration ? configuration.Name : null)];
|
||||
|
||||
int index = sortedContainers.IndexOf(container);
|
||||
|
||||
if (container.Services.GetRequiredService<ContainerConfiguration>() is ContainerConfiguration configuration)
|
||||
{
|
||||
if (container.Services.GetRequiredService<IServiceFactory>() is IServiceFactory serviceFactory)
|
||||
{
|
||||
if (serviceFactory.Create<ContainerNavigationViewModel>(configuration.Name) is ContainerNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(new InsertEventArgs<IMainNavigationViewModel>(index, viewModel),
|
||||
nameof(MainViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerComponent(IComponentBuilder builder) : Component(builder),
|
||||
IContainerComponent;
|
||||
@@ -1,18 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerFactory(IComponentFactory componentFactory) :
|
||||
IContainerFactory
|
||||
{
|
||||
public IComponentHost? Create(string name)
|
||||
{
|
||||
if (componentFactory.Create<IContainerComponent, ContainerConfiguration>($"Locker:{name}",
|
||||
new ContainerConfiguration { Name = name }) is IComponentHost host)
|
||||
{
|
||||
return host;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ContainerHeaderViewModel :
|
||||
ObservableCollection
|
||||
{
|
||||
public ContainerHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
|
||||
Add<CreateItemActionViewModel>(0);
|
||||
Add<SearchContainerActionViewModel>(2);
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerInitializer(IEnumerable<IConfigurationDescriptor<ContainerConfiguration>> configurations,
|
||||
IComponentFactory componentFactory,
|
||||
IContainerHostCollection vaults) : IInitializer
|
||||
{
|
||||
public async Task Initialize()
|
||||
{
|
||||
foreach (IConfigurationDescriptor<ContainerConfiguration> configuration in configurations)
|
||||
{
|
||||
if (componentFactory.Create<IContainerComponent,
|
||||
ContainerConfiguration>(configuration.Section, configuration.Value)
|
||||
is IComponentHost host)
|
||||
{
|
||||
vaults.Add(host);
|
||||
await host.StartAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,10 @@ public partial class CreateItemActionViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
NamedComponent named,
|
||||
int index) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
NamedComponent named) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = index;
|
||||
private int index = 0;
|
||||
|
||||
[ObservableProperty]
|
||||
private string named = $"{named}";
|
||||
|
||||
@@ -5,7 +5,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class CreateItemHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||
public class CreateItemHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IHandler<CreateEventArgs<(Guid, ItemConfiguration)>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(CreateEventArgs<(Guid, ItemConfiguration)> args,
|
||||
@@ -17,7 +17,7 @@ public class CreateItemHandler(IDbContextFactory<ContainerDbContext> dbContextFa
|
||||
{
|
||||
string? name = configuration.Name;
|
||||
|
||||
using ContainerDbContext context = dbContextFactory.CreateDbContext();
|
||||
using LockerContext context = dbContextFactory.CreateDbContext();
|
||||
EntityEntry<ItemEntry>? result = null;
|
||||
|
||||
await Task.Run(async () =>
|
||||
|
||||
@@ -5,30 +5,30 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class CreateContainerHandler(IContainerFactory componentFactory,
|
||||
public class CreateLockerHandler(ILockerFactory componentFactory,
|
||||
IPublisher publisher) :
|
||||
IHandler<CreateEventArgs<Container>, bool>
|
||||
IHandler<CreateEventArgs<Locker>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(CreateEventArgs<Container> args,
|
||||
public async Task<bool> Handle(CreateEventArgs<Locker> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is Container container && container.Name is { Length: > 0 } name &&
|
||||
container.Password is { Length: > 0 } password)
|
||||
if (args.Value is Locker locker && locker.Name is { Length: > 0 } name &&
|
||||
locker.Password is { Length: > 0 } password)
|
||||
{
|
||||
if (componentFactory.Create(name) is IComponentHost host)
|
||||
{
|
||||
ISecurityKeyFactory keyVaultFactory = host.Services.GetRequiredService<ISecurityKeyFactory>();
|
||||
IValueStore<SecurityKey> secureKeyStore = host.Services.GetRequiredService<IValueStore<SecurityKey>>();
|
||||
IContainerStorageFactory containerFactory = host.Services.GetRequiredService<IContainerStorageFactory>();
|
||||
ILockerStorageFactory lockerStorageFactory = host.Services.GetRequiredService<ILockerStorageFactory>();
|
||||
|
||||
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password)) is SecurityKey key)
|
||||
{
|
||||
secureKeyStore.Set(key);
|
||||
|
||||
if (await containerFactory.Create(name, key))
|
||||
if (await lockerStorageFactory.Create(name, key))
|
||||
{
|
||||
IWritableConfiguration<ContainerConfiguration> configuration =
|
||||
host.Services.GetRequiredService<IWritableConfiguration<ContainerConfiguration>>();
|
||||
IWritableConfiguration<LockerConfiguration> configuration =
|
||||
host.Services.GetRequiredService<IWritableConfiguration<LockerConfiguration>>();
|
||||
|
||||
configuration.Write(args => args.Key = $"{Convert.ToBase64String(key.Salt)}:{Convert.ToBase64String(key.EncryptedKey)}:{Convert.ToBase64String(key.DecryptedKey)}");
|
||||
host.Start();
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class CreateContainerNavigationViewModel(IServiceProvider provider,
|
||||
public partial class CreateLockerNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class CreateContainerViewModel(IServiceProvider provider,
|
||||
public partial class CreateLockerViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IPublisher publisher,
|
||||
IMediator mediator,
|
||||
@@ -22,5 +22,5 @@ public partial class CreateContainerViewModel(IServiceProvider provider,
|
||||
private string password;
|
||||
|
||||
public async Task<bool> Confirm() =>
|
||||
await Mediator.Handle<CreateEventArgs<Container>, bool>(Create.As(new Container(Name, Password)));
|
||||
await Mediator.Handle<CreateEventArgs<Locker>, bool>(Create.As(new Locker(Name, Password)));
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class CreatedItemHandler(IServiceProvider serviceProvider,
|
||||
int index = cache.IndexOf(item);
|
||||
valueStore.Set(item);
|
||||
|
||||
publisher.Publish(Insert.As(index, viewModel), nameof(ContainerViewModel));
|
||||
publisher.Publish(Insert.As(index, viewModel), nameof(LockerViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record DropdownEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string[]? Values { get; set; }
|
||||
}
|
||||
+7
-7
@@ -4,10 +4,10 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class FilterContainerNavigationViewModel : Observable,
|
||||
IContainerNavigationViewModel,
|
||||
INotificationHandler<ActivatedEventArgs<Container>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Container>>
|
||||
public partial class FilterLockerNavigationViewModel : Observable,
|
||||
ILockerNavigationViewModel,
|
||||
INotificationHandler<ActivatedEventArgs<Locker>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Locker>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool activated;
|
||||
@@ -18,7 +18,7 @@ public partial class FilterContainerNavigationViewModel : Observable,
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
public FilterContainerNavigationViewModel(IServiceProvider provider,
|
||||
public FilterLockerNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -29,10 +29,10 @@ public partial class FilterContainerNavigationViewModel : Observable,
|
||||
Filter = filter;
|
||||
}
|
||||
|
||||
public Task Handle(DeactivatedEventArgs<Container> args) =>
|
||||
public Task Handle(DeactivatedEventArgs<Locker> args) =>
|
||||
Task.FromResult(Activated = false);
|
||||
|
||||
public Task Handle(ActivatedEventArgs<Container> args) =>
|
||||
public Task Handle(ActivatedEventArgs<Locker> args) =>
|
||||
Task.FromResult(Activated = true);
|
||||
|
||||
[RelayCommand]
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record Form
|
||||
{
|
||||
public ICollection<FormEntry>? Entries { get; set; }
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record FormEntry;
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record FormField : FormEntry
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public object? Value { get; set; }
|
||||
|
||||
public FormFieldType Type { get; set; }
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public enum FormFieldType
|
||||
{
|
||||
Attachments,
|
||||
Date,
|
||||
Masked,
|
||||
Note,
|
||||
Number,
|
||||
Options,
|
||||
Password,
|
||||
Phone,
|
||||
Text,
|
||||
Time,
|
||||
Url
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record FormGroup : FormEntry
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public ICollection<FormField>? Fields { get; set; }
|
||||
}
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerHost : IComponentHost;
|
||||
public interface ILockerComponent : IComponent;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault
|
||||
{
|
||||
public interface IContainerFactory
|
||||
public interface ILockerFactory
|
||||
{
|
||||
IComponentHost? Create(string name);
|
||||
}
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerComponent : IComponent;
|
||||
public interface ILockerHost : IComponentHost;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerHostCollection :
|
||||
public interface ILockerHostCollection :
|
||||
IEnumerable<IComponentHost>
|
||||
{
|
||||
void Add(IComponentHost host);
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerNavigationViewModel :
|
||||
public interface ILockerNavigationViewModel :
|
||||
ISelectable,
|
||||
IDisposable;
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerStorageFactory
|
||||
public interface ILockerStorageFactory
|
||||
{
|
||||
Task<bool> Create(string name, SecurityKey key);
|
||||
}
|
||||
@@ -14,4 +14,14 @@ public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
||||
{
|
||||
[ObservableProperty]
|
||||
private IContentTemplate template = template;
|
||||
|
||||
public override Task OnActivated()
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<LockerCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
|
||||
})));
|
||||
|
||||
return base.OnActivated();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public partial class ItemCollectionViewModel :
|
||||
INotificationHandler<NotifyEventArgs<Filter>>,
|
||||
INotificationHandler<NotifyEventArgs<Search>>
|
||||
{
|
||||
private ContainerViewModelConfiguration configuration;
|
||||
private LockerViewModelConfiguration configuration;
|
||||
|
||||
public ItemCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
@@ -17,7 +17,7 @@ public partial class ItemCollectionViewModel :
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
ContainerViewModelConfiguration configuration,
|
||||
LockerViewModelConfiguration configuration,
|
||||
string? filter = null) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
@@ -48,7 +48,18 @@ public partial class ItemCollectionViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override IAggerate OnPrepareAggregation(object? key) =>
|
||||
Aggerate.With<ItemNavigationViewModel, ContainerViewModelConfiguration>(configuration)
|
||||
public override Task OnActivated()
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<LockerCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<CreateItemActionViewModel>(),
|
||||
Factory.Create<SearchLockerActionViewModel>(),
|
||||
})));
|
||||
|
||||
return base.OnActivated();
|
||||
}
|
||||
|
||||
protected override IAggerate OnAggerate(object? key) =>
|
||||
Aggerate.With<ItemNavigationViewModel, LockerViewModelConfiguration>(configuration)
|
||||
with { Key = key };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ItemCommandHeaderCollection(IList<IDisposable> list) :
|
||||
ReadOnlyCollection<IDisposable>(list);
|
||||
@@ -10,14 +10,15 @@ public partial class ItemCommandHeaderViewModel(IServiceProvider provider,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<NotifyEventArgs<CommandCollection>>
|
||||
INotificationHandler<NotifyEventArgs<ItemCommandHeaderCollection>>
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(NotifyEventArgs<CommandCollection> args)
|
||||
public Task Handle(NotifyEventArgs<ItemCommandHeaderCollection> args)
|
||||
{
|
||||
Clear();
|
||||
if (args.Value is CommandCollection commandCollection)
|
||||
|
||||
if (args.Value is ItemCommandHeaderCollection commandCollection)
|
||||
{
|
||||
foreach (IDisposable command in commandCollection)
|
||||
{
|
||||
|
||||
@@ -3,4 +3,40 @@
|
||||
public record ItemConfiguration
|
||||
{
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public IList<ItemSectionConfiguration>? Sections { get; set; }
|
||||
|
||||
public static ItemConfiguration CreditCard => new()
|
||||
{
|
||||
Name = "Credit Card",
|
||||
Sections = new List<ItemSectionConfiguration>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
Label = "Cardholder name"
|
||||
},
|
||||
new DropdownEntryConfiguration
|
||||
{
|
||||
Label = "Type",
|
||||
},
|
||||
new MaskedTextEntryConfiguration
|
||||
{
|
||||
Label = "Card number"
|
||||
},
|
||||
new MaskedTextEntryConfiguration
|
||||
{
|
||||
Label = "Expiry date"
|
||||
},
|
||||
new MaskedTextEntryConfiguration
|
||||
{
|
||||
Label = "Card verification code"
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[JsonDerivedType(typeof(DropdownEntryConfiguration), typeDiscriminator: "Dropdown")]
|
||||
[JsonDerivedType(typeof(MaskedTextEntryConfiguration), typeDiscriminator: "MaskedText")]
|
||||
[JsonDerivedType(typeof(NoteEntryConfiguration), typeDiscriminator: "Note")]
|
||||
[JsonDerivedType(typeof(NumberEntryConfiguration), typeDiscriminator: "Number")]
|
||||
[JsonDerivedType(typeof(PasswordEntryConfiguration), typeDiscriminator: "Password")]
|
||||
[JsonDerivedType(typeof(TextEntryConfiguration), typeDiscriminator: "Text")]
|
||||
public record ItemEntryConfiguration
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Label { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public object? Value { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record ItemSectionConfiguration
|
||||
{
|
||||
public IList<ItemEntryConfiguration> Entries { get; set; } = new List<ItemEntryConfiguration>();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public partial class ItemViewModel :
|
||||
|
||||
public Task Handle(UpdateEventArgs<Item> args)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<ConfirmItemActionViewModel>(),
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
@@ -63,7 +63,7 @@ public partial class ItemViewModel :
|
||||
|
||||
public Task Handle(CancelEventArgs<Item> args)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<EditItemActionViewModel>(),
|
||||
Factory.Create<ArchiveItemActionViewModel>(),
|
||||
@@ -74,7 +74,7 @@ public partial class ItemViewModel :
|
||||
|
||||
public Task Handle(ConfirmEventArgs<Item> args)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||
Factory.Create<EditItemActionViewModel>(),
|
||||
@@ -88,7 +88,7 @@ public partial class ItemViewModel :
|
||||
{
|
||||
if (!Immutable)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<ConfirmItemActionViewModel>(),
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
@@ -96,14 +96,14 @@ public partial class ItemViewModel :
|
||||
}
|
||||
else if (Archived)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<UnarchiveItemActionViewModel>(),
|
||||
})));
|
||||
}
|
||||
else
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||
Factory.Create<EditItemActionViewModel>(),
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record Container
|
||||
public record Locker
|
||||
{
|
||||
public Container(string name, string password)
|
||||
public Locker(string name, string password)
|
||||
{
|
||||
Name = name;
|
||||
Password = password;
|
||||
}
|
||||
|
||||
public Container(string password)
|
||||
public Locker(string password)
|
||||
{
|
||||
Password = password;
|
||||
}
|
||||
|
||||
public Container()
|
||||
public Locker()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerActivatedHandler(ILockerHostCollection lockers,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ActivatedEventArgs<IComponentHost>>
|
||||
{
|
||||
public Task Handle(ActivatedEventArgs<IComponentHost> args)
|
||||
{
|
||||
if (args.Value is IComponentHost locker)
|
||||
{
|
||||
List<IComponentHost> sortedLockers = [.. lockers, locker];
|
||||
sortedLockers = [.. sortedLockers.OrderBy(x => x.GetConfiguration<LockerConfiguration>() is LockerConfiguration configuration ? configuration.Name : null)];
|
||||
|
||||
int index = sortedLockers.IndexOf(locker);
|
||||
|
||||
if (locker.Services.GetRequiredService<LockerConfiguration>() is LockerConfiguration configuration)
|
||||
{
|
||||
if (locker.Services.GetRequiredService<IServiceFactory>() is IServiceFactory serviceFactory)
|
||||
{
|
||||
if (serviceFactory.Create<LockerNavigationViewModel>(configuration.Name) is LockerNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(new InsertEventArgs<IMainNavigationViewModel>(index, viewModel),
|
||||
nameof(MainViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerCommandHeaderCollection(IList<IDisposable> list) :
|
||||
ReadOnlyCollection<IDisposable>(list);
|
||||
@@ -0,0 +1,6 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerComponent(IComponentBuilder builder) : Component(builder),
|
||||
ILockerComponent;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record ContainerConfiguration :
|
||||
public record LockerConfiguration :
|
||||
ComponentConfiguration
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerConnection(string connection)
|
||||
public class LockerConnection(string connection)
|
||||
{
|
||||
private readonly string connection = connection;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerFactory(IComponentFactory componentFactory) :
|
||||
ILockerFactory
|
||||
{
|
||||
public IComponentHost? Create(string name)
|
||||
{
|
||||
if (componentFactory.Create<ILockerComponent, LockerConfiguration>($"Locker:{name}",
|
||||
new LockerConfiguration { Name = name }) is IComponentHost host)
|
||||
{
|
||||
return host;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class LockerHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<NotifyEventArgs<LockerCommandHeaderCollection>>
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(NotifyEventArgs<LockerCommandHeaderCollection> args)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (args.Value is LockerCommandHeaderCollection commandCollection)
|
||||
{
|
||||
foreach (IDisposable command in commandCollection)
|
||||
{
|
||||
Add(command);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerHostCollection :
|
||||
IContainerHostCollection
|
||||
public class LockerHostCollection :
|
||||
ILockerHostCollection
|
||||
|
||||
{
|
||||
private readonly List<IComponentHost> hosts = [];
|
||||
@@ -0,0 +1,22 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class LockerInitializer(IEnumerable<IConfigurationDescriptor<LockerConfiguration>> configurations,
|
||||
IComponentFactory componentFactory,
|
||||
ILockerHostCollection lockers) : IInitializer
|
||||
{
|
||||
public async Task Initialize()
|
||||
{
|
||||
foreach (IConfigurationDescriptor<LockerConfiguration> configuration in configurations)
|
||||
{
|
||||
if (componentFactory.Create<ILockerComponent,
|
||||
LockerConfiguration>(configuration.Section, configuration.Value)
|
||||
is IComponentHost host)
|
||||
{
|
||||
lockers.Add(host);
|
||||
await host.StartAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ContainerNavigationViewModel :
|
||||
ObservableCollection<IContainerNavigationViewModel>,
|
||||
public partial class LockerNavigationViewModel :
|
||||
ObservableCollection<ILockerNavigationViewModel>,
|
||||
IMainNavigationViewModel,
|
||||
INotificationHandler<OpenedEventArgs<Container>>,
|
||||
INotificationHandler<ClosedEventArgs<Container>>,
|
||||
INotificationHandler<ActivatedEventArgs<Container>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Container>>
|
||||
INotificationHandler<OpenedEventArgs<Locker>>,
|
||||
INotificationHandler<ClosedEventArgs<Locker>>,
|
||||
INotificationHandler<ActivatedEventArgs<Locker>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Locker>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool activated;
|
||||
@@ -26,7 +26,7 @@ public partial class ContainerNavigationViewModel :
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
public ContainerNavigationViewModel(IServiceProvider provider,
|
||||
public LockerNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -41,7 +41,7 @@ public partial class ContainerNavigationViewModel :
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
public Task Handle(OpenedEventArgs<Container> args)
|
||||
public Task Handle(OpenedEventArgs<Locker> args)
|
||||
{
|
||||
Add<AllNavigationViewModel>("All");
|
||||
Add<StarredNavigationViewModel>("Starred");
|
||||
@@ -52,7 +52,7 @@ public partial class ContainerNavigationViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(ClosedEventArgs<Container> args)
|
||||
public Task Handle(ClosedEventArgs<Locker> args)
|
||||
{
|
||||
Opened = true;
|
||||
Clear();
|
||||
@@ -60,9 +60,9 @@ public partial class ContainerNavigationViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(DeactivatedEventArgs<Container> args) =>
|
||||
public Task Handle(DeactivatedEventArgs<Locker> args) =>
|
||||
Task.FromResult(Activated = false);
|
||||
|
||||
public Task Handle(ActivatedEventArgs<Container> args) =>
|
||||
public Task Handle(ActivatedEventArgs<Locker> args) =>
|
||||
Task.FromResult(Activated = true);
|
||||
}
|
||||
@@ -6,19 +6,19 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerStorageFactory(IValueStore<ContainerConnection> connection,
|
||||
public class LockerStorageFactory(IValueStore<LockerConnection> connection,
|
||||
IHostEnvironment environment,
|
||||
IServiceProvider provider) :
|
||||
IContainerStorageFactory
|
||||
ILockerStorageFactory
|
||||
{
|
||||
public async Task<bool> Create(string name,
|
||||
SecurityKey key)
|
||||
{
|
||||
connection.Set(new ContainerConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||
connection.Set(new LockerConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||
$".vault;Mode=ReadWriteCreate;Pooling=false;Password={Convert.ToBase64String(key.DecryptedKey)}"));
|
||||
|
||||
IDbContextFactory<ContainerDbContext> dbContextFactory = provider.GetRequiredService<IDbContextFactory<ContainerDbContext>>();
|
||||
using ContainerDbContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
IDbContextFactory<LockerContext> dbContextFactory = provider.GetRequiredService<IDbContextFactory<LockerContext>>();
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ContainerViewModel :
|
||||
public partial class LockerViewModel :
|
||||
Observable
|
||||
{
|
||||
[ObservableProperty]
|
||||
@@ -11,7 +11,7 @@ public partial class ContainerViewModel :
|
||||
|
||||
[ObservableProperty]
|
||||
private string filter;
|
||||
public ContainerViewModel(IServiceProvider provider,
|
||||
public LockerViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -26,13 +26,13 @@ public partial class ContainerViewModel :
|
||||
|
||||
public override async Task OnActivated()
|
||||
{
|
||||
Publisher.Publish(Activated.As<Container>());
|
||||
Publisher.Publish(Activated.As<Locker>());
|
||||
await base.OnActivated();
|
||||
}
|
||||
|
||||
public override async Task OnDeactivated()
|
||||
{
|
||||
Publisher.Publish(Deactivated.As<Container>());
|
||||
Publisher.Publish(Deactivated.As<Locker>());
|
||||
await base.OnDeactivated();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record ContainerViewModelConfiguration
|
||||
public record LockerViewModelConfiguration
|
||||
{
|
||||
public string? Filter { get; set; } = "All";
|
||||
|
||||
@@ -16,7 +16,7 @@ public partial class ManageViewModel :
|
||||
{
|
||||
Template = template;
|
||||
|
||||
Add<CreateContainerNavigationViewModel>();
|
||||
Add<CreateLockerNavigationViewModel>();
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record MaskedTextEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Pattern { get; set; }
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class ModifiedItemHandler(IServiceProvider serviceProvider,
|
||||
int newIndex = cache.IndexOf(newItem);
|
||||
valueStore.Set(newItem);
|
||||
|
||||
publisher.Publish(MoveTo.As<ItemNavigationViewModel>(oldIndex, newIndex), nameof(ContainerViewModel));
|
||||
publisher.Publish(MoveTo.As<ItemNavigationViewModel>(oldIndex, newIndex), nameof(LockerViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record NoteEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record NumberEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using System.Text;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class OpenContainerHandler(ContainerConfiguration configuration,
|
||||
ISecurityKeyFactory keyVaultFactory,
|
||||
IContainerStorageFactory vaultStorage) :
|
||||
IHandler<ActivateEventArgs<Container>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(ActivateEventArgs<Container> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is Container container && configuration.Name is { Length: > 0 } name && container.Password is { Length: > 0 } password)
|
||||
{
|
||||
if (configuration.Key?.Split(':') is { Length: >= 2 } keyPart)
|
||||
{
|
||||
byte[]? salt = Convert.FromBase64String(keyPart[0]);
|
||||
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
|
||||
|
||||
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
|
||||
{
|
||||
if (await vaultStorage.Create(name, key))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Text;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class OpenLockerHandler(LockerConfiguration configuration,
|
||||
ISecurityKeyFactory securityKeyFactory,
|
||||
ILockerStorageFactory lockerStorageFactory) :
|
||||
IHandler<ActivateEventArgs<Locker>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(ActivateEventArgs<Locker> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is Locker locker && configuration.Name is { Length: > 0 } name && locker.Password is { Length: > 0 } password)
|
||||
{
|
||||
if (configuration.Key?.Split(':') is { Length: >= 2 } keyPart)
|
||||
{
|
||||
byte[]? salt = Convert.FromBase64String(keyPart[0]);
|
||||
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
|
||||
|
||||
if (securityKeyFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
|
||||
{
|
||||
if (await lockerStorageFactory.Create(name, key))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class OpenContainerViewModel(IServiceProvider provider,
|
||||
public partial class OpenLockerViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -20,9 +20,9 @@ public partial class OpenContainerViewModel(IServiceProvider provider,
|
||||
{
|
||||
if (Password is { Length: > 0 })
|
||||
{
|
||||
if (await Mediator.Handle<ActivateEventArgs<Container>, bool>(Activate.As(new Container(Password))))
|
||||
if (await Mediator.Handle<ActivateEventArgs<Locker>, bool>(Activate.As(new Locker(Password))))
|
||||
{
|
||||
Publisher.Publish(Opened.As<Container>());
|
||||
Publisher.Publish(Opened.As<Locker>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record PasswordEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record QueryContainerConfiguration
|
||||
public record QueryLockerConfiguration
|
||||
{
|
||||
public string? Filter { get; set; }
|
||||
|
||||
@@ -5,15 +5,15 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||
IHandler<RequestEventArgs<QueryContainerConfiguration>, IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>>
|
||||
public class QueryLockerHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IHandler<RequestEventArgs<QueryLockerConfiguration>, IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>>
|
||||
{
|
||||
public async Task<IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>> Handle(RequestEventArgs<QueryContainerConfiguration> args,
|
||||
public async Task<IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>> Handle(RequestEventArgs<QueryLockerConfiguration> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
List<(Guid Id, string? Name, bool Favourite, bool Archived)> items = [];
|
||||
|
||||
if (args.Value is QueryContainerConfiguration queryConfiguration)
|
||||
if (args.Value is QueryLockerConfiguration queryConfiguration)
|
||||
{
|
||||
ExpressionStarter<ItemEntry> predicate =
|
||||
PredicateBuilder.New<ItemEntry>(true);
|
||||
@@ -40,7 +40,7 @@ public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbConte
|
||||
|
||||
var results = await Task.Run(async () =>
|
||||
{
|
||||
using ContainerDbContext context = dbContextFactory.CreateDbContext();
|
||||
using LockerContext context = dbContextFactory.CreateDbContext();
|
||||
return await context.Set<ItemEntry>()
|
||||
.Where(predicate)
|
||||
.Select(x => new
|
||||
@@ -1,21 +0,0 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class SearchContainerActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
int index) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = index;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class SearchLockerActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = 2;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
|
||||
public partial class BackContainerActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = 2;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
@@ -8,4 +8,4 @@ public partial class StarredNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record TextEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
public class UnarchiveItemHandler(IValueStore<Item> valueStore,
|
||||
IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||
IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
INotificationHandler<UnarchiveEventArgs<Item>>
|
||||
{
|
||||
public async Task Handle(UnarchiveEventArgs<Item> args)
|
||||
@@ -16,7 +16,7 @@ public class UnarchiveItemHandler(IValueStore<Item> valueStore,
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
using ContainerDbContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
|
||||
if (await context.FindAsync<ItemEntry>(item.Id) is ItemEntry result)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class UpdateItemHander(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||
public class UpdateItemHander(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IHandler<UpdateEventArgs<(Guid, ItemConfiguration)>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(UpdateEventArgs<(Guid, ItemConfiguration)> args,
|
||||
@@ -15,7 +15,7 @@ public class UpdateItemHander(IDbContextFactory<ContainerDbContext> dbContextFac
|
||||
try
|
||||
{
|
||||
string? name = configuration.Name;
|
||||
using ContainerDbContext context = dbContextFactory.CreateDbContext();
|
||||
using LockerContext context = dbContextFactory.CreateDbContext();
|
||||
ItemEntry? result = null;
|
||||
|
||||
await Task.Run(async () =>
|
||||
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class UpdateItemStateHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||
public class UpdateItemStateHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IHandler<UpdateEventArgs<(Guid, int)>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(UpdateEventArgs<(Guid, int)> args,
|
||||
@@ -14,7 +14,7 @@ public class UpdateItemStateHandler(IDbContextFactory<ContainerDbContext> dbCont
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
using ContainerDbContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
using LockerContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
if (await context.FindAsync<ItemEntry>(id) is ItemEntry result)
|
||||
{
|
||||
result.State = state;
|
||||
|
||||
Reference in New Issue
Block a user