Mass rename
This commit is contained in:
+3
-3
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.AddVaultContentActionView"
|
||||
x:Class="Bitvault.Avalonia.AddItemActionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:AddVaultContentActionViewModel">
|
||||
x:DataType="vm:AddItemActionViewModel">
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Width="{StaticResource ButtonWidth}"
|
||||
@@ -15,7 +15,7 @@
|
||||
ToolTip.Tip="Add item">
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Click">
|
||||
<NavigateAction Context="{Binding Named, StringFormat='{}{0}:Content'}" Route="AddVaultContent" />
|
||||
<NavigateAction Context="{Binding Named, StringFormat='{}{0}:Content'}" Route="AddItem" />
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Button>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class AddItemActionView : UserControl
|
||||
{
|
||||
public AddItemActionView() => InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.AddVaultContentCommandHeaderView"
|
||||
x:Class="Bitvault.Avalonia.AddItemCommandHeaderView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:AddVaultContentCommandHeaderViewModel">
|
||||
x:DataType="vm:AddItemCommandHeaderViewModel">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<x:Double x:Key="ButtonWidth">40</x:Double>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class AddItemCommandHeaderView : UserControl
|
||||
{
|
||||
public AddItemCommandHeaderView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.AddVaultContentView"
|
||||
x:Class="Bitvault.Avalonia.AddItemView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:AddVaultContentViewModel">
|
||||
x:DataType="vm:AddItemViewModel">
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Loaded">
|
||||
<NavigateAction Context="{Binding Named, StringFormat='{}{0}:ContentHeader'}" Route="AddVaultContentCommandHeader" />
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class AddItemView : UserControl
|
||||
{
|
||||
public AddItemView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class AddVaultContentActionView : UserControl
|
||||
{
|
||||
public AddVaultContentActionView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class AddVaultContentCommandHeaderView : UserControl
|
||||
{
|
||||
public AddVaultContentCommandHeaderView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class AddVaultContentView : UserControl
|
||||
{
|
||||
public AddVaultContentView() => InitializeComponent();
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Context="Main" Route="Vault">
|
||||
<NavigateAction Context="Main" Route="Container">
|
||||
<NavigateAction.ParameterBindings>
|
||||
<ParameterBinding Key="Filter" Value="{Binding Filter}" />
|
||||
</NavigateAction.ParameterBindings>
|
||||
|
||||
@@ -23,7 +23,7 @@ public partial class App : Application
|
||||
public override async void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
IHost? host = DefaultHostBuilder.Create()
|
||||
.AddConfiguration<VaultConfiguration>(args => args.Name = "Personal",
|
||||
.AddConfiguration<ContainerConfiguration>(args => args.Name = "Personal",
|
||||
"Vault:*")
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
@@ -35,7 +35,7 @@ public partial class App : Application
|
||||
services.AddTemplate<MainWindowViewModel, MainWindow>("MainWindow");
|
||||
}
|
||||
|
||||
services.AddTransient<IVaultComponent> (provider => Component.Create<VaultComponent>(provider, args =>
|
||||
services.AddTransient<IContainerComponent> (provider => Component.Create<ContainerComponent>(provider, args =>
|
||||
{
|
||||
args.AddServices(services =>
|
||||
{
|
||||
@@ -46,55 +46,55 @@ public partial class App : Application
|
||||
services.AddTransient<IPasswordHasher, PasswordHasher>();
|
||||
services.AddTransient<IKeyDeriver, KeyDeriver>();
|
||||
|
||||
services.AddTransient<IVaultKeyFactory, VaultKeyFactory>();
|
||||
services.AddTransient<IVaultStorage, VaultStorage>();
|
||||
services.TryAddSingleton<IContainer<VaultKey>, Container<VaultKey>>();
|
||||
services.TryAddSingleton<IContainer<VaultStorageConnection>, Container<VaultStorageConnection>>();
|
||||
services.AddTransient<ISecurityKeyFactory, SecurityKeyFactory>();
|
||||
services.AddTransient<IContainer, ContainerFactory>();
|
||||
services.TryAddSingleton<IContainer<SecurityKey>, Container<SecurityKey>>();
|
||||
services.TryAddSingleton<IContainer<ContaienrConnection>, Container<ContaienrConnection>>();
|
||||
|
||||
services.AddDbContextFactory<VaultDbContext>((provider, args) =>
|
||||
{
|
||||
if (provider.GetRequiredService<IContainer<VaultStorageConnection>>()
|
||||
is IContainer<VaultStorageConnection> connection)
|
||||
if (provider.GetRequiredService<IContainer<ContaienrConnection>>()
|
||||
is IContainer<ContaienrConnection> connection)
|
||||
{
|
||||
args.UseSqlite($"{connection.Value}");
|
||||
}
|
||||
});
|
||||
|
||||
services.AddHandler<OpenVaultHandler>();
|
||||
services.AddHandler<OpenContainerHandler>();
|
||||
|
||||
services.AddTemplate<VaultNavigationViewModel, VaultNavigationView>();
|
||||
services.AddTemplate<ContainerNavigationViewModel, ContainerNavigationView>();
|
||||
services.AddTemplate<AllNavigationViewModel, AllNavigationView>();
|
||||
services.AddTemplate<StarredNavigationViewModel, StarredNavigationView>();
|
||||
services.AddTemplate<CategoriesNavigationViewModel, CategoriesNavigationView>();
|
||||
services.AddTemplate<ArchiveNavigationViewModel, ArchiveNavigationView>();
|
||||
|
||||
services.AddTemplate<OpenVaultViewModel, OpenView>("OpenVault");
|
||||
services.AddTemplate<OpenContainerViewModel, OpenView>("OpenContainer");
|
||||
|
||||
services.AddTemplate<VaultViewModel, VaultView>("Vault");
|
||||
services.AddHandler<VaultViewModelHandler>();
|
||||
services.AddTemplate<ContainerViewModel, ContainerView>("Container");
|
||||
services.AddHandler<ContainerViewModelHandler>();
|
||||
|
||||
services.AddTemplate<VaultSearchHeaderViewModel, VaultSearchHeaderView>("VaultSearchHeader");
|
||||
services.AddTemplate<VaultHeaderViewModel, VaultHeaderView>("VaultHeader");
|
||||
services.AddTemplate<AddVaultContentActionViewModel, AddVaultContentActionView>();
|
||||
services.AddTemplate<SearchHeaderViewModel, SearchHeaderView>("SearchHeader");
|
||||
services.AddTemplate<ContainerHeaderViewModel, ContainerHeaderView>("ContainerHeader");
|
||||
services.AddTemplate<AddItemActionViewModel, AddItemActionView>();
|
||||
|
||||
services.AddTemplate<VaultContentNavigationViewModel, VaultContentNavigationView>();
|
||||
services.AddTemplate<VaultContentViewModel, VaultContentView>("VaultContent");
|
||||
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
||||
services.AddTemplate<ItemViewModel, ItemView>("AddItem");
|
||||
|
||||
services.AddTemplate<AddVaultContentViewModel, AddVaultContentView>("AddVaultContent");
|
||||
services.AddTemplate<AddVaultContentCommandHeaderViewModel, AddVaultContentCommandHeaderView>("AddVaultContentCommandHeader");
|
||||
services.AddTemplate<AddItemViewModel, AddItemView>("AddAddItem");
|
||||
services.AddTemplate<AddItemCommandHeaderViewModel, AddItemCommandHeaderView>("AddVaultContentCommandHeader");
|
||||
|
||||
services.AddTemplate<ConfirmVaultContentActionViewModel, ConfirmVaultContentActionView>();
|
||||
services.AddTemplate<DismissVaultContentActionViewModel, DismissVaultContentActionView>();
|
||||
services.AddTemplate<ConfirmItemActionViewModel, ConfirmVaultContentActionView>();
|
||||
services.AddTemplate<DismissItemActionViewModel, DismissItemActionView>();
|
||||
|
||||
services.AddTemplate<VaultContentHeaderViewModel, VaultContentHeaderView>();
|
||||
services.AddTemplate<ItemHeaderViewModel, ItemHeaderView>();
|
||||
});
|
||||
})!);
|
||||
|
||||
services.AddTransient<IVaultComponentFactory, VaultComponentFactory>();
|
||||
services.AddHandler<CreateVaultHandler>();
|
||||
services.AddTransient<IContainerComponentFactory, ContainerComponentFactory>();
|
||||
services.AddHandler<CreateContainerHandler>();
|
||||
|
||||
services.AddSingleton<IVaultHostCollection, VaultHostCollection>();
|
||||
services.AddInitializer<VaultCollectionInitializer>();
|
||||
services.AddSingleton<IContainerHostCollection, ContainerHostCollection>();
|
||||
services.AddInitializer<ContainerCollectionInitializer>();
|
||||
|
||||
services.AddTemplate<MainViewModel, MainView>("Main");
|
||||
services.AddHandler<MainViewModelHandler>();
|
||||
@@ -104,8 +104,8 @@ public partial class App : Application
|
||||
services.AddTemplate<ManageNavigationViewModel, ManageNavigationView>();
|
||||
services.AddTemplate<ManageViewModel, ManageView>("Manage");
|
||||
|
||||
services.AddTemplate<CreateVaultNavigationViewModel, CreateVaultNavigationView>();
|
||||
services.AddTemplate<CreateVaultViewModel, CreateVaultView>("CreateVault");
|
||||
services.AddTemplate<CreateContainerNavigationViewModel, CreateContainerNavigationView>();
|
||||
services.AddTemplate<CreateContainerViewModel, CreateContainerView>("CreateContainer");
|
||||
})
|
||||
.Build();
|
||||
|
||||
|
||||
@@ -40,14 +40,26 @@
|
||||
<ProjectReference Include="..\Toolkit\Toolkit.UI.Controls.Avalonia\Toolkit.UI.Controls.Avalonia.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="AddVaultContentActionView.axaml.cs">
|
||||
<DependentUpon>AddVaultContentActionView.axaml</DependentUpon>
|
||||
<Compile Update="AddItemActionView.axaml.cs">
|
||||
<DependentUpon>AddItemActionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="AddVaultContentCommandHeaderView.axaml.cs">
|
||||
<DependentUpon>AddVaultContentCommandHeaderView.axaml</DependentUpon>
|
||||
<Compile Update="AddItemCommandHeaderView.axaml.cs">
|
||||
<DependentUpon>AddItemCommandHeaderView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="VaultContentHeaderView.axaml.cs">
|
||||
<DependentUpon>VaultContentHeaderView.axaml</DependentUpon>
|
||||
<Compile Update="AddItemView.axaml.cs">
|
||||
<DependentUpon>AddItemView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="CreateContainerNavigationView.axaml.cs">
|
||||
<DependentUpon>CreateContainerNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="CreateContainerView.axaml.cs">
|
||||
<DependentUpon>CreateContainerView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="DismissItemActionView.axaml.cs">
|
||||
<DependentUpon>DismissItemActionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ItemHeaderView.axaml.cs">
|
||||
<DependentUpon>ItemHeaderView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="OpenView.axaml.cs">
|
||||
<DependentUpon>OpenView.axaml</DependentUpon>
|
||||
@@ -55,11 +67,23 @@
|
||||
<Compile Update="ManageNavigationView.axaml.cs">
|
||||
<DependentUpon>ManageNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="VaultHeaderView.axaml.cs">
|
||||
<DependentUpon>VaultHeaderView.axaml</DependentUpon>
|
||||
<Compile Update="ContainerHeaderView.axaml.cs">
|
||||
<DependentUpon>ContainerHeaderView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="VaultNavigationView.axaml.cs">
|
||||
<DependentUpon>VaultNavigationView.axaml</DependentUpon>
|
||||
<Compile Update="ItemNavigationView.axaml.cs">
|
||||
<DependentUpon>ItemNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ItemView.axaml.cs">
|
||||
<DependentUpon>ItemView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ContainerNavigationView.axaml.cs">
|
||||
<DependentUpon>ContainerNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="SearchHeaderView.axaml.cs">
|
||||
<DependentUpon>SearchHeaderView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ContainerView.axaml.cs">
|
||||
<DependentUpon>ContainerView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.VaultHeaderView"
|
||||
x:Class="Bitvault.Avalonia.ContainerHeaderView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:VaultHeaderViewModel">
|
||||
x:DataType="vm:ContainerHeaderViewModel">
|
||||
<UserControl.Resources>
|
||||
<x:Double x:Key="ButtonWidth">40</x:Double>
|
||||
<x:Double x:Key="ButtonHeight">36</x:Double>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ContainerHeaderView : UserControl
|
||||
{
|
||||
public ContainerHeaderView() => InitializeComponent();
|
||||
}
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
<NavigationViewItem
|
||||
x:Class="Bitvault.Avalonia.VaultNavigationView"
|
||||
x:Class="Bitvault.Avalonia.ContainerNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:Name="NavigationViewItem"
|
||||
x:DataType="vm:VaultNavigationViewModel"
|
||||
x:DataType="vm:ContainerNavigationViewModel"
|
||||
Content="{Binding Name}"
|
||||
IsExpanded="{Binding Expanded}"
|
||||
IsSelected="{Binding Selected}"
|
||||
@@ -19,7 +19,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Context="Main" Route="OpenVault" />
|
||||
<NavigateAction Context="Main" Route="OpenContainer" />
|
||||
<ChangePropertyAction
|
||||
PropertyName="SelectsOnInvoked"
|
||||
TargetObject="{Binding #NavigationViewItem}"
|
||||
@@ -33,7 +33,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Context="Main" Route="Vault" />
|
||||
<NavigateAction Context="Main" Route="Container" />
|
||||
<ChangePropertyAction
|
||||
PropertyName="SelectsOnInvoked"
|
||||
TargetObject="{Binding #NavigationViewItem}"
|
||||
@@ -48,7 +48,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Opened}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Context="Main" Route="OpenVault" />
|
||||
<NavigateAction Context="Main" Route="OpenContainer" />
|
||||
</ConditionAction>
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
@@ -57,7 +57,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Context="Main" Route="Vault" />
|
||||
<NavigateAction Context="Main" Route="Container" />
|
||||
<InvokeNavigationViewItemAction />
|
||||
</ConditionAction>
|
||||
</AttachedEventTriggerBehaviour>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ContainerNavigationView : NavigationViewItem
|
||||
{
|
||||
public ContainerNavigationView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.VaultView"
|
||||
x:Class="Bitvault.Avalonia.ContainerView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:VaultViewModel">
|
||||
x:DataType="vm:ContainerViewModel">
|
||||
<Grid ColumnDefinitions="320,Auto,*" RowDefinitions="Auto,*">
|
||||
<ContentControl
|
||||
Grid.Row="0"
|
||||
@@ -12,7 +12,7 @@
|
||||
Margin="4,4,0,0">
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Loaded">
|
||||
<NavigateAction Context="{Binding $self}" Route="VaultHeader" />
|
||||
<NavigateAction Context="{Binding $self}" Route="ContainerHeader" />
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</ContentControl>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ContainerView : UserControl
|
||||
{
|
||||
public ContainerView() => InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
<SettingsExpander
|
||||
x:Class="Bitvault.Avalonia.CreateVaultNavigationView"
|
||||
x:Class="Bitvault.Avalonia.CreateContainerNavigationView"
|
||||
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 Route="CreateVault" />
|
||||
<NavigateAction Route="CreateContainer" />
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Button>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateContainerNavigationView : SettingsExpander
|
||||
{
|
||||
public CreateContainerNavigationView() => InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<ContentDialog
|
||||
x:Class="Bitvault.Avalonia.CreateVaultView"
|
||||
x:Class="Bitvault.Avalonia.CreateContainerView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
Title="Create vault"
|
||||
x:DataType="vm:CreateVaultViewModel"
|
||||
x:DataType="vm:CreateContainerViewModel"
|
||||
CloseButtonText="Cancel"
|
||||
PrimaryButtonText="Create">
|
||||
<StackPanel Width="400">
|
||||
@@ -0,0 +1,8 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateContainerView : ContentDialog
|
||||
{
|
||||
public CreateContainerView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateVaultNavigationView : SettingsExpander
|
||||
{
|
||||
public CreateVaultNavigationView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateVaultView : ContentDialog
|
||||
{
|
||||
public CreateVaultView() => InitializeComponent();
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.DismissVaultContentActionView"
|
||||
x:Class="Bitvault.Avalonia.DismissItemActionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Button
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class DismissItemActionView : UserControl
|
||||
{
|
||||
public DismissItemActionView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class DismissVaultContentActionView : UserControl
|
||||
{
|
||||
public DismissVaultContentActionView() => InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.VaultContentHeaderView"
|
||||
x:Class="Bitvault.Avalonia.ItemHeaderView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:VaultContentHeaderViewModel">
|
||||
x:DataType="vm:ItemHeaderViewModel">
|
||||
<StackPanel Grid.Column="1" Spacing="18">
|
||||
<PersonPicture
|
||||
Width="96"
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ItemHeaderView : UserControl
|
||||
{
|
||||
public ItemHeaderView() => InitializeComponent();
|
||||
}
|
||||
+3
-3
@@ -1,14 +1,14 @@
|
||||
<ListBoxItem
|
||||
x:Class="Bitvault.Avalonia.VaultContentNavigationView"
|
||||
x:Class="Bitvault.Avalonia.ItemNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:Name="Name"
|
||||
x:CompileBindings="False"
|
||||
x:DataType="vm:VaultContentNavigationViewModel">
|
||||
x:DataType="vm:ItemNavigationViewModel">
|
||||
<Interaction.Behaviors>
|
||||
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
||||
<NavigateAction Context="{Binding Named, StringFormat='{}{0}:Content'}" Route="VaultContent" />
|
||||
<NavigateAction Context="{Binding Named, StringFormat='{}{0}:Content'}" Route="AddItem" />
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ItemNavigationView : ListBoxItem
|
||||
{
|
||||
public ItemNavigationView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.VaultContentView"
|
||||
x:Class="Bitvault.Avalonia.ItemView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
Vault content placeholder
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ItemView : UserControl
|
||||
{
|
||||
public ItemView() => InitializeComponent();
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Loaded">
|
||||
<NavigateRegionAction Name="Main">
|
||||
<NavigateAction Context="Main" Route="Vault" />
|
||||
<NavigateAction Context="Main" Route="Container" />
|
||||
</NavigateRegionAction>
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
|
||||
@@ -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:OpenVaultViewModel">
|
||||
x:DataType="vm:OpenContainerViewModel">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBox
|
||||
Width="300"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.VaultSearchHeaderView"
|
||||
x:Class="Bitvault.Avalonia.SearchHeaderView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<AutoCompleteBox VerticalAlignment="Center" />
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class SearchHeaderView : UserControl
|
||||
{
|
||||
public SearchHeaderView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.VaultCommandView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
Welcome to Avalonia!
|
||||
</UserControl>
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class VaultCommandView : UserControl
|
||||
{
|
||||
public VaultCommandView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class VaultContentHeaderView : UserControl
|
||||
{
|
||||
public VaultContentHeaderView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia
|
||||
{
|
||||
public partial class VaultContentNavigationView : ListBoxItem
|
||||
{
|
||||
public VaultContentNavigationView()
|
||||
{
|
||||
InitializeComponent();
|
||||
Tapped += VaultContentNavigationView_Tapped;
|
||||
}
|
||||
|
||||
private void VaultContentNavigationView_Tapped(object? sender, global::Avalonia.Input.TappedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class VaultContentView : UserControl
|
||||
{
|
||||
public VaultContentView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class VaultHeaderView : UserControl
|
||||
{
|
||||
public VaultHeaderView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using Toolkit.UI.Avalonia;
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia
|
||||
{
|
||||
public partial class VaultNavigationView : NavigationViewItem
|
||||
{
|
||||
public VaultNavigationView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Test(object? sender, ItemInvokedEventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia
|
||||
{
|
||||
public partial class VaultSearchHeaderView : UserControl
|
||||
{
|
||||
public VaultSearchHeaderView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class VaultView : UserControl
|
||||
{
|
||||
public VaultView() => InitializeComponent();
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class AddVaultContentActionViewModel(IServiceProvider provider,
|
||||
public partial class AddItemActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
+4
-4
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class AddVaultContentCommandHeaderViewModel : ObservableCollectionViewModel
|
||||
public partial class AddItemCommandHeaderViewModel : ObservableCollectionViewModel
|
||||
{
|
||||
public AddVaultContentCommandHeaderViewModel(IServiceProvider provider,
|
||||
public AddItemCommandHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -12,8 +12,8 @@ public partial class AddVaultContentCommandHeaderViewModel : ObservableCollectio
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Add<ConfirmVaultContentActionViewModel>();
|
||||
Add<DismissVaultContentActionViewModel>();
|
||||
Add<ConfirmItemActionViewModel>();
|
||||
Add<DismissItemActionViewModel>();
|
||||
|
||||
Template = template;
|
||||
}
|
||||
@@ -3,13 +3,13 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class AddVaultContentViewModel :
|
||||
ObservableCollectionViewModel<IVaultContentEntryViewModel>
|
||||
public partial class AddItemViewModel :
|
||||
ObservableCollectionViewModel<IItemViewModel>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string named;
|
||||
|
||||
public AddVaultContentViewModel(IServiceProvider provider,
|
||||
public AddItemViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -21,15 +21,15 @@ public partial class AddVaultContentViewModel :
|
||||
Template = template;
|
||||
Named = $"{named}";
|
||||
|
||||
Add<VaultContentHeaderViewModel>();
|
||||
Add<ItemHeaderViewModel>();
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
public Task<bool> Confirm()
|
||||
{
|
||||
VaultContentConfiguration configuration = new();
|
||||
foreach (IVaultContentEntryViewModel item in this)
|
||||
ItemConfiguration configuration = new();
|
||||
foreach (IItemViewModel item in this)
|
||||
{
|
||||
item.Invoke(configuration);
|
||||
}
|
||||
@@ -8,4 +8,4 @@ public partial class AllNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
string filter) : FilterVaultNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||
string filter) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||
|
||||
@@ -8,4 +8,4 @@ public partial class ArchiveNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterVaultNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -8,4 +8,4 @@ public partial class CategoriesNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterVaultNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class DeleteVaultContentActionViewModel(IServiceProvider provider,
|
||||
public partial class ConfirmItemActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultStorageConnection(string connection)
|
||||
public class ContaienrConnection(string connection)
|
||||
{
|
||||
private readonly string connection = connection;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record Vault<TValue>(TValue? Value = default);
|
||||
public record SecureStorage<TValue>(TValue? Value = default);
|
||||
|
||||
public record Vault
|
||||
{
|
||||
@@ -18,9 +18,9 @@ public record Vault
|
||||
}
|
||||
|
||||
|
||||
public static Vault<TValue> As<TValue>(TValue value) => new(value);
|
||||
public static SecureStorage<TValue> As<TValue>(TValue value) => new(value);
|
||||
|
||||
public static Vault<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||
public static SecureStorage<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||
|
||||
|
||||
[MaybeNull]
|
||||
@@ -0,0 +1,21 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerCollectionInitializer(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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerComponent(IComponentBuilder builder) : Component(builder),
|
||||
IContainerComponent
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerComponentFactory(IComponentFactory componentFactory) :
|
||||
IContainerComponentFactory
|
||||
{
|
||||
public IComponentHost? Create(string name)
|
||||
{
|
||||
if (componentFactory.Create<IContainerComponent, ContainerConfiguration>($"Vault:{name}",
|
||||
new ContainerConfiguration { Name = name }) is IComponentHost host)
|
||||
{
|
||||
return host;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record VaultConfiguration : ComponentConfiguration
|
||||
public record ContainerConfiguration : ComponentConfiguration
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
@@ -6,15 +6,15 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultStorage(IContainer<VaultStorageConnection> connection,
|
||||
public class ContainerFactory(IContainer<ContaienrConnection> connection,
|
||||
IHostEnvironment environment,
|
||||
IServiceProvider provider) :
|
||||
IVaultStorage
|
||||
IContainer
|
||||
{
|
||||
public async Task<bool> Create(string name,
|
||||
VaultKey key)
|
||||
SecurityKey key)
|
||||
{
|
||||
connection.Set(new VaultStorageConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||
connection.Set(new ContaienrConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||
$".vault;Mode=ReadWriteCreate;Pooling=false;Password={Convert.ToBase64String(key.DecryptedKey)}"));
|
||||
|
||||
IDbContextFactory<VaultDbContext> dbContextFactory = provider.GetRequiredService<IDbContextFactory<VaultDbContext>>();
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class VaultHeaderViewModel : ObservableCollectionViewModel<string, IDisposable>,
|
||||
INotificationHandler<Vault<Filter<string>>>
|
||||
public partial class ContainerHeaderViewModel : ObservableCollectionViewModel<string, IDisposable>,
|
||||
INotificationHandler<SecureStorage<Filter<string>>>
|
||||
{
|
||||
public VaultHeaderViewModel(IServiceProvider provider,
|
||||
public ContainerHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -15,12 +15,12 @@ public partial class VaultHeaderViewModel : ObservableCollectionViewModel<string
|
||||
{
|
||||
Template = template;
|
||||
|
||||
Add<AddVaultContentActionViewModel>();
|
||||
Add<AddItemActionViewModel>();
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
public Task Handle(Vault<Filter<string>> args,
|
||||
public Task Handle(SecureStorage<Filter<string>> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (args.Value is Filter<string> filter)
|
||||
@@ -3,8 +3,8 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultHostCollection :
|
||||
IVaultHostCollection
|
||||
public class ContainerHostCollection :
|
||||
IContainerHostCollection
|
||||
|
||||
{
|
||||
private readonly List<IComponentHost> hosts = [];
|
||||
@@ -3,13 +3,13 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class VaultNavigationViewModel :
|
||||
ObservableCollectionViewModel<IVaultNavigationViewModel>,
|
||||
public partial class ContainerNavigationViewModel :
|
||||
ObservableCollectionViewModel<IContainerNavigationViewModel>,
|
||||
IMainNavigationViewModel,
|
||||
INotificationHandler<Vault<Opened>>,
|
||||
INotificationHandler<Vault<Closed>>,
|
||||
INotificationHandler<Vault<Activated>>,
|
||||
INotificationHandler<Vault<Deactivated>>
|
||||
INotificationHandler<SecureStorage<Opened>>,
|
||||
INotificationHandler<SecureStorage<Closed>>,
|
||||
INotificationHandler<SecureStorage<Activated>>,
|
||||
INotificationHandler<SecureStorage<Deactivated>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool activated;
|
||||
@@ -26,7 +26,7 @@ public partial class VaultNavigationViewModel :
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
public VaultNavigationViewModel(IServiceProvider provider,
|
||||
public ContainerNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -41,7 +41,7 @@ public partial class VaultNavigationViewModel :
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
public Task Handle(Vault<Opened> args,
|
||||
public Task Handle(SecureStorage<Opened> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
Add<AllNavigationViewModel>("All");
|
||||
@@ -53,7 +53,7 @@ public partial class VaultNavigationViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(Vault<Closed> args,
|
||||
public Task Handle(SecureStorage<Closed> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
Opened = true;
|
||||
@@ -62,11 +62,11 @@ public partial class VaultNavigationViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(Vault<Deactivated> args,
|
||||
public Task Handle(SecureStorage<Deactivated> args,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
Task.FromResult(Activated = false);
|
||||
|
||||
public Task Handle(Vault<Activated> args,
|
||||
public Task Handle(SecureStorage<Activated> args,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
Task.FromResult(Activated = true);
|
||||
}
|
||||
@@ -4,8 +4,8 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
|
||||
[Enumerate(nameof(VaultViewModel))]
|
||||
public partial class VaultViewModel(IServiceProvider provider,
|
||||
[Enumerate(nameof(ContainerViewModel))]
|
||||
public partial class ContainerViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -13,8 +13,8 @@ public partial class VaultViewModel(IServiceProvider provider,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
NamedComponent named,
|
||||
string? filter = null) : ObservableCollectionViewModel<VaultContentNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<Vault<Filter<string>>>
|
||||
string? filter = null) : ObservableCollectionViewModel<ItemNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<SecureStorage<Filter<string>>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? filter = filter;
|
||||
@@ -36,7 +36,7 @@ public partial class VaultViewModel(IServiceProvider provider,
|
||||
await base.Deactivated();
|
||||
}
|
||||
|
||||
public async Task Handle(Vault<Filter<string>> args,
|
||||
public async Task Handle(SecureStorage<Filter<string>> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (args.Value is Filter<string> filter)
|
||||
@@ -47,5 +47,5 @@ public partial class VaultViewModel(IServiceProvider provider,
|
||||
}
|
||||
|
||||
protected override IEnumerate PrepareEnumeration(object? key) =>
|
||||
Enumerate<VaultContentNavigationViewModel>.With(new VaultViewModelOptions { Filter = Filter }) with { Key = key };
|
||||
Enumerate<ItemNavigationViewModel>.With(new ContainerViewModelConfiguration { Filter = Filter }) with { Key = key };
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record VaultViewModelOptions
|
||||
public record ContainerViewModelConfiguration
|
||||
{
|
||||
public string? Filter { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerViewModelHandler(IServiceFactory factory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<Enumerate<ItemNavigationViewModel, ContainerViewModelConfiguration>>
|
||||
{
|
||||
public async Task Handle(Enumerate<ItemNavigationViewModel, ContainerViewModelConfiguration> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (args.Options?.Filter is "All")
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
if (factory.Create<ItemNavigationViewModel>("Name " + i, "Description " + 1) is ItemNavigationViewModel viewModel)
|
||||
{
|
||||
await publisher.Publish(new Create<ItemNavigationViewModel>(viewModel),
|
||||
nameof(ContainerViewModel), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.Options?.Filter is "Starred")
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
if (factory.Create<ItemNavigationViewModel>("Name " + i, "Description " + 1) is ItemNavigationViewModel viewModel)
|
||||
{
|
||||
await publisher.Publish(new Create<ItemNavigationViewModel>(viewModel),
|
||||
nameof(ContainerViewModel), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.Options?.Filter is "Archive")
|
||||
{
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
if (factory.Create<ItemNavigationViewModel>("Name " + i, "Description " + 1) is ItemNavigationViewModel viewModel)
|
||||
{
|
||||
await publisher.Publish(new Create<ItemNavigationViewModel>(viewModel),
|
||||
nameof(ContainerViewModel), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class CreateVaultHandler(IVaultComponentFactory componentFactory) :
|
||||
public class CreateContainerHandler(IContainerComponentFactory componentFactory) :
|
||||
IHandler<Create<Vault>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(Create<Vault> args,
|
||||
@@ -16,18 +16,18 @@ public class CreateVaultHandler(IVaultComponentFactory componentFactory) :
|
||||
{
|
||||
if (componentFactory.Create(name) is IComponentHost host)
|
||||
{
|
||||
IVaultKeyFactory keyVaultFactory = host.Services.GetRequiredService<IVaultKeyFactory>();
|
||||
IContainer<VaultKey> vaultKeyContainer = host.Services.GetRequiredService<IContainer<VaultKey>>();
|
||||
IVaultStorage vaultStorage = host.Services.GetRequiredService<IVaultStorage>();
|
||||
ISecurityKeyFactory keyVaultFactory = host.Services.GetRequiredService<ISecurityKeyFactory>();
|
||||
IContainer<SecurityKey> vaultKeyContainer = host.Services.GetRequiredService<IContainer<SecurityKey>>();
|
||||
IContainer vaultStorage = host.Services.GetRequiredService<IContainer>();
|
||||
|
||||
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password)) is VaultKey key)
|
||||
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password)) is SecurityKey key)
|
||||
{
|
||||
vaultKeyContainer.Set(key);
|
||||
|
||||
if (await vaultStorage.Create(name, key))
|
||||
{
|
||||
IWritableConfiguration<VaultConfiguration> configuration =
|
||||
host.Services.GetRequiredService<IWritableConfiguration<VaultConfiguration>>();
|
||||
IWritableConfiguration<ContainerConfiguration> configuration =
|
||||
host.Services.GetRequiredService<IWritableConfiguration<ContainerConfiguration>>();
|
||||
|
||||
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 CreateVaultNavigationViewModel(IServiceProvider provider,
|
||||
public partial class CreateContainerNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class CreateVaultViewModel(IServiceProvider provider,
|
||||
public partial class CreateContainerViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IPublisher publisher,
|
||||
IMediator mediator,
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ConfirmVaultContentActionViewModel(IServiceProvider provider,
|
||||
public partial class DeleteItemActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class DismissVaultContentActionViewModel(IServiceProvider provider,
|
||||
public partial class DismissItemActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class EditVaultContentActionViewModel(IServiceProvider provider,
|
||||
public partial class EditItemActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
+7
-7
@@ -4,10 +4,10 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class FilterVaultNavigationViewModel : ObservableViewModel,
|
||||
IVaultNavigationViewModel,
|
||||
INotificationHandler<Vault<Activated>>,
|
||||
INotificationHandler<Vault<Deactivated>>
|
||||
public partial class FilterContainerNavigationViewModel : ObservableViewModel,
|
||||
IContainerNavigationViewModel,
|
||||
INotificationHandler<SecureStorage<Activated>>,
|
||||
INotificationHandler<SecureStorage<Deactivated>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool activated;
|
||||
@@ -18,7 +18,7 @@ public partial class FilterVaultNavigationViewModel : ObservableViewModel,
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
public FilterVaultNavigationViewModel(IServiceProvider provider,
|
||||
public FilterContainerNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -29,11 +29,11 @@ public partial class FilterVaultNavigationViewModel : ObservableViewModel,
|
||||
Filter = filter;
|
||||
}
|
||||
|
||||
public Task Handle(Vault<Deactivated> args,
|
||||
public Task Handle(SecureStorage<Deactivated> args,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
Task.FromResult(Activated = false);
|
||||
|
||||
public Task Handle(Vault<Activated> args,
|
||||
public Task Handle(SecureStorage<Activated> args,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
Task.FromResult(Activated = true);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainer
|
||||
{
|
||||
Task<bool> Create(string name, SecurityKey key);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerComponent : IComponent;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault
|
||||
{
|
||||
public interface IVaultComponentFactory
|
||||
public interface IContainerComponentFactory
|
||||
{
|
||||
IComponentHost? Create(string name);
|
||||
}
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IVaultHost : IComponentHost;
|
||||
public interface IContainerHost : IComponentHost;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IVaultHostCollection :
|
||||
public interface IContainerHostCollection :
|
||||
IEnumerable<IComponentHost>
|
||||
{
|
||||
void Add(IComponentHost host);
|
||||
@@ -0,0 +1,5 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IContainerNavigationViewModel : ISelectable;
|
||||
@@ -0,0 +1,6 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IItemViewModel :
|
||||
IValueInvoker<ItemConfiguration>;
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IVaultKeyFactory
|
||||
public interface ISecurityKeyFactory
|
||||
{
|
||||
VaultKey? Create(byte[] phrase,
|
||||
SecurityKey? Create(byte[] phrase,
|
||||
byte[]? encryptedKey = null,
|
||||
byte[]? salt = null);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IVaultComponent : IComponent;
|
||||
|
||||
public class VaultComponent(IComponentBuilder builder) : Component(builder),
|
||||
IVaultComponent
|
||||
{
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Bitvault
|
||||
{
|
||||
public interface IVaultConnectionPersistence
|
||||
{
|
||||
void Dispose();
|
||||
string? Get(string key);
|
||||
void Set(string key, string connection);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IVaultContentEntryViewModel :
|
||||
IValueInvoker<VaultContentConfiguration>;
|
||||
@@ -1,5 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IVaultNavigationViewModel : ISelectable;
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IVaultStorage
|
||||
{
|
||||
Task<bool> Create(string name, VaultKey key);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record VaultContentConfiguration
|
||||
public record ItemConfiguration
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class VaultContentHeaderViewModel(IServiceProvider provider,
|
||||
public partial class ItemHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) : ObservableViewModel<string, string>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IVaultContentEntryViewModel
|
||||
IItemViewModel
|
||||
{
|
||||
public void Invoke(VaultContentConfiguration args) =>
|
||||
public void Invoke(ItemConfiguration args) =>
|
||||
args.Name = Value;
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class VaultContentNavigationViewModel(IServiceProvider provider,
|
||||
public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultContentViewModel(IServiceProvider provider,
|
||||
public class ItemViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
public class MainViewModelHandler(IPublisher publisher,
|
||||
IVaultHostCollection vaults) :
|
||||
IContainerHostCollection vaults) :
|
||||
INotificationHandler<Enumerate<IMainNavigationViewModel>>
|
||||
{
|
||||
public async Task Handle(Enumerate<IMainNavigationViewModel> args,
|
||||
@@ -12,11 +12,11 @@ public class MainViewModelHandler(IPublisher publisher,
|
||||
{
|
||||
foreach (IComponentHost vault in vaults)
|
||||
{
|
||||
if (vault.Services.GetRequiredService<VaultConfiguration>() is VaultConfiguration configuration)
|
||||
if (vault.Services.GetRequiredService<ContainerConfiguration>() is ContainerConfiguration configuration)
|
||||
{
|
||||
if (vault.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||
{
|
||||
if (factory.Create<VaultNavigationViewModel>(configuration.Name) is VaultNavigationViewModel viewModel)
|
||||
if (factory.Create<ContainerNavigationViewModel>(configuration.Name) is ContainerNavigationViewModel viewModel)
|
||||
{
|
||||
await publisher.Publish(new Create<IMainNavigationViewModel>(viewModel),
|
||||
nameof(MainViewModel), cancellationToken);
|
||||
|
||||
@@ -16,7 +16,7 @@ public partial class ManageViewModel :
|
||||
{
|
||||
Template = template;
|
||||
|
||||
Add<CreateVaultNavigationViewModel>();
|
||||
Add<CreateContainerNavigationViewModel>();
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
@@ -3,9 +3,9 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class OpenVaultHandler(VaultConfiguration configuration,
|
||||
IVaultKeyFactory keyVaultFactory,
|
||||
IVaultStorage vaultStorage) :
|
||||
public class OpenContainerHandler(ContainerConfiguration configuration,
|
||||
ISecurityKeyFactory keyVaultFactory,
|
||||
IContainer vaultStorage) :
|
||||
IHandler<Open<Vault>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(Open<Vault> args,
|
||||
@@ -18,7 +18,7 @@ public class OpenVaultHandler(VaultConfiguration configuration,
|
||||
byte[]? salt = Convert.FromBase64String(keyPart[0]);
|
||||
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
|
||||
|
||||
if ( keyVaultFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is VaultKey key)
|
||||
if ( keyVaultFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
|
||||
{
|
||||
if (await vaultStorage.Create(name, key))
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class OpenVaultViewModel(IServiceProvider provider,
|
||||
public partial class OpenContainerViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class VaultSearchHeaderViewModel(IServiceProvider provider,
|
||||
public partial class SearchHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record VaultKey(byte[] Salt, byte[] EncryptedKey, byte[] DecryptedKey) :
|
||||
public record SecurityKey(byte[] Salt, byte[] EncryptedKey, byte[] DecryptedKey) :
|
||||
IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultKeyFactory(IKeyGenerator generator,
|
||||
public class SecurityKeyFactory(IKeyGenerator generator,
|
||||
IKeyDeriver deriver,
|
||||
IEncryptor encryptor,
|
||||
IDecryptor decryptor) :
|
||||
IVaultKeyFactory
|
||||
ISecurityKeyFactory
|
||||
{
|
||||
public VaultKey? Create(byte[] phrase,
|
||||
public SecurityKey? Create(byte[] phrase,
|
||||
byte[]? encryptedKey = null,
|
||||
byte[]? salt = null)
|
||||
{
|
||||
@@ -28,7 +28,7 @@ public class VaultKeyFactory(IKeyGenerator generator,
|
||||
return default;
|
||||
}
|
||||
|
||||
return new VaultKey(salt, encryptedKey, decryptedKey);
|
||||
return new SecurityKey(salt, encryptedKey, decryptedKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ public partial class StarredNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterVaultNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -1,21 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultCollectionInitializer(IEnumerable<IConfigurationDescriptor<VaultConfiguration>> configurations,
|
||||
IComponentFactory componentFactory,
|
||||
IVaultHostCollection vaults) : IInitializer
|
||||
{
|
||||
public async Task Initialize()
|
||||
{
|
||||
foreach (IConfigurationDescriptor<VaultConfiguration> configuration in configurations)
|
||||
{
|
||||
if (componentFactory.Create<IVaultComponent, VaultConfiguration>(configuration.Section, configuration.Value) is IComponentHost host)
|
||||
{
|
||||
vaults.Add(host);
|
||||
await host.StartAsync();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultComponentFactory(IComponentFactory componentFactory) :
|
||||
IVaultComponentFactory
|
||||
{
|
||||
public IComponentHost? Create(string name)
|
||||
{
|
||||
if (componentFactory.Create<IVaultComponent, VaultConfiguration>($"Vault:{name}",
|
||||
new VaultConfiguration { Name = name }) is IComponentHost host)
|
||||
{
|
||||
return host;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user