using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; using Bitvault.Data; using HotAvalonia; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; using System; using System.Collections.Generic; using System.Linq; using Toolkit.Avalonia; using Toolkit.Foundation; namespace Bitvault.Avalonia; public partial class App : Application { public override void Initialize() { this.EnableHotReload(); AvaloniaXamlLoader.Load(this); } public override async void OnFrameworkInitializationCompleted() { IHost? host = DefaultHostBuilder.Create() .AddConfiguration("Locker:*") .AddConfiguration("Item:*") .AddConfiguration("Item:Bank Account", ItemConfiguration.BankAccount) .AddConfiguration("Item:Credit Card", ItemConfiguration.CreditCard) .AddConfiguration("Item:Document", ItemConfiguration.Document) .AddConfiguration("Item:Driving Licence", ItemConfiguration.DrivingLicence) .AddConfiguration("Item:Identity", ItemConfiguration.Identity) .AddConfiguration("Item:Login", ItemConfiguration.Login) .AddConfiguration("Item:Note", ItemConfiguration.Note) .AddConfiguration("Item:Password", ItemConfiguration.Password) .ConfigureServices((context, services) => { services.AddAvalonia(); services.AddHandler(); if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime) { services.AddTemplate("MainWindow"); } services.AddHandler(); services.AddTransient(provider => Component.Create(provider, args => { args.AddServices(services => { services.AddTransient>>(provider => Comparer>.Create((x, z) => StringComparer.CurrentCultureIgnoreCase.Compare(x.Value.Item2, z.Value.Item2))); services.AddCache>(); services.AddTransient(_ => provider.GetServices>()); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(provider => { IEnumerable> items = provider.GetServices>() ?? Enumerable.Empty>(); return new ItemConfigurationCollection(items.ToDictionary(x => x.Name, x => (Func)(() => x.Value))); }); services.TryAddSingleton, DecoratorService>(); services.TryAddSingleton, DecoratorService>(); services.AddDbContextFactory((provider, args) => { if (provider.GetRequiredService>() is IDecoratorService connection) { args.UseSqlite($"{connection.Value}"); } }); services.AddHandler(); services.AddHandler(); services.AddHandler(); services.AddHandler(); services.AddHandler(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate("OpenLocker"); services.AddScoped(); services.AddTemplate("Locker"); services.AddTemplate("ContentItemCollection"); services.AddSingleton>, DecoratorService>>(); services.AddTransient(provider => provider.GetRequiredService>>().Value!); services.AddHandler(); services.AddTemplate("LockerHeader"); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate("ItemCategoryCollection"); services.AddTemplate(); services.AddHandler(); services.AddScoped>, DecoratorService>>(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate("EmptyItemCollection"); services.AddTemplate("Item"); services.AddTemplate(); services.AddTemplate(); services.AddHandler(); services.AddHandler(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddSingleton>, DecoratorService>>(); services.AddTransient(provider => provider.GetRequiredService>>().Value!); services.AddTemplate("ItemCommandHeader"); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); services.AddHandler(nameof(ItemState.Write)); services.AddHandler(nameof(ItemState.New)); services.AddHandler(); services.AddHandler(); services.AddHandler(); services.AddHandler(); services.AddHandler(nameof(TextEntryConfiguration)); services.AddHandler(nameof(PasswordEntryConfiguration)); services.AddHandler(nameof(MaskedTextEntryConfiguration)); services.AddHandler(nameof(DropdownEntryConfiguration)); services.AddHandler(ServiceLifetime.Singleton); services.AddHandler(ServiceLifetime.Singleton); }); })!); services.AddTransient(); services.AddHandler(); services.AddSingleton(); services.AddInitializer(); services.AddTemplate("Main"); services.AddHandler(); services.AddTransient(); services.AddTemplate(); services.AddTemplate("Manage"); services.AddTemplate(); services.AddTemplate("CreateLocker"); }) .Build(); await host.RunAsync(); } }