Added the abilty to load configuration sections using * pattern
This commit is contained in:
@@ -18,13 +18,15 @@ public partial class App : Application
|
||||
public override async void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
IHost? host = DefaultBuilder.Create()
|
||||
.AddConfiguration<VaultConfiguration>(args => args.Name = "Personal",
|
||||
"Vault:*")
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddAvalonia();
|
||||
services.AddHandler<AppHandler>();
|
||||
|
||||
services.AddTransient<IVaultComponent, VaultComponent>();
|
||||
services.AddInitializer<VaultComponentsInitializer>();
|
||||
services.AddInitializer<VaultConfigurationInitializer>();
|
||||
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime)
|
||||
{
|
||||
@@ -32,11 +34,19 @@ public partial class App : Application
|
||||
}
|
||||
|
||||
services.AddSingleton<IVaultHostCollection, VaultHostCollection>();
|
||||
services.AddSingleton<IVaultFactory, VaultFactory>();
|
||||
services.AddHandler<VaultHandler>();
|
||||
|
||||
services.AddTemplate<MainViewModel, MainView>("Main");
|
||||
services.AddHandler<MainViewModelHandler>();
|
||||
|
||||
services.AddConfiguration<VaultConfiguration>(args => args.Name = "Personal", "Vault:Personal");
|
||||
services.AddTransient<FooterViewModel>();
|
||||
|
||||
services.AddTemplate<ManageNavigationViewModel, ManageNavigationView>();
|
||||
services.AddTemplate<ManageViewModel, ManageView>("Manage");
|
||||
|
||||
services.AddTemplate<CreateVaultNavigationViewModel, CreateVaultNavigationView>();
|
||||
services.AddTemplate<CreateVaultViewModel, CreateVaultView>("CreateVault");
|
||||
})
|
||||
.Build();
|
||||
|
||||
|
||||
@@ -27,4 +27,9 @@
|
||||
<ProjectReference Include="..\Toolkit\Toolkit.UI.Avalonia\Toolkit.UI.Avalonia.csproj" />
|
||||
<ProjectReference Include="..\Toolkit\Toolkit.UI.Controls.Avalonia\Toolkit.UI.Controls.Avalonia.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="ManageNavigationView.axaml.cs">
|
||||
<DependentUpon>ManageNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,16 @@
|
||||
<SettingsExpander
|
||||
x:Class="Bitvault.Avalonia.CreateVaultNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Description="Keep organized by separating your things into vaults."
|
||||
Header="Create a new vault">
|
||||
<SettingsExpander.Footer>
|
||||
<Button MinWidth="132" Content="Create vault">
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Click">
|
||||
<NavigateAction Route="CreateVault" />
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Button>
|
||||
</SettingsExpander.Footer>
|
||||
</SettingsExpander>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateVaultNavigationView : SettingsExpander
|
||||
{
|
||||
public CreateVaultNavigationView() => InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<ContentDialog
|
||||
x:Class="Bitvault.Avalonia.CreateVaultView"
|
||||
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"
|
||||
CloseButtonText="Cancel"
|
||||
PrimaryButtonText="Create">
|
||||
<StackPanel Width="400">
|
||||
<TextBox
|
||||
Margin="0,0,0,18"
|
||||
Text="{Binding Name}"
|
||||
Watermark="Enter vault name" />
|
||||
<TextBox Margin="0,0,0,18" Watermark="Enter password" />
|
||||
<TextBox Watermark="Confirm password" />
|
||||
</StackPanel>
|
||||
</ContentDialog>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateVaultView : ContentDialog
|
||||
{
|
||||
public CreateVaultView() => InitializeComponent();
|
||||
}
|
||||
@@ -4,7 +4,10 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:MainViewModel">
|
||||
<NavigationView MenuItemTemplate="{Binding Template}" MenuItemsSource="{Binding}">
|
||||
<NavigationView
|
||||
FooterMenuItemsSource="{Binding Footer}"
|
||||
MenuItemTemplate="{Binding Template}"
|
||||
MenuItemsSource="{Binding}">
|
||||
<Frame x:Name="Main">
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Loaded">
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<NavigationViewItem
|
||||
x:Class="Bitvault.Avalonia.ManageNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Content="Manage Vaults">
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Tapped">
|
||||
<NavigateAction Context="Main" Route="Manage" />
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</NavigationViewItem>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ManageNavigationView : NavigationViewItem
|
||||
{
|
||||
public ManageNavigationView() => InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.ManageView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ManageViewModel">
|
||||
<ScrollViewer Padding="12" HorizontalAlignment="Stretch">
|
||||
<ItemsControl
|
||||
MaxWidth="768"
|
||||
ItemTemplate="{ReflectionBinding Template}"
|
||||
ItemsSource="{Binding}" />
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ManageView : UserControl
|
||||
{
|
||||
public ManageView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Toolkit.Foundation;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
@@ -17,6 +18,5 @@ public class VaultComponent :
|
||||
|
||||
services.AddTemplate<VaultViewModel, VaultView>("Vault");
|
||||
services.AddTemplate<LockViewModel, LockView>("Lock");
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
Content="{Binding Name}"
|
||||
MenuItemsSource="{Binding}">
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Loaded">
|
||||
<EventTriggerBehavior EventName="Tapped">
|
||||
<NavigateAction Context="Main" Route="Lock" />
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
|
||||
Reference in New Issue
Block a user