43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using WinGreedWPF.StartupHelpers;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using System.Windows;
|
|
using WpfLibrary;
|
|
|
|
namespace WinGreedWPF;
|
|
|
|
public partial class App : Application
|
|
{
|
|
public static IHost? AppHost { get; private set; }
|
|
|
|
public App()
|
|
{
|
|
AppHost = Host.CreateDefaultBuilder()
|
|
.ConfigureServices((hostContext, services) =>
|
|
{
|
|
services.AddSingleton<MainWindow>();
|
|
services.AddFormFactory<ChildForm>();
|
|
services.AddFormFactory<ExtraChild>();
|
|
services.AddTransient<IDataAccess, DataAccess>();
|
|
})
|
|
.Build();
|
|
}
|
|
|
|
protected override async void OnStartup(StartupEventArgs e)
|
|
{
|
|
await AppHost!.StartAsync();
|
|
|
|
var startupForm = AppHost.Services.GetRequiredService<MainWindow>();
|
|
startupForm.Show();
|
|
|
|
base.OnStartup(e);
|
|
}
|
|
|
|
protected override async void OnExit(ExitEventArgs e)
|
|
{
|
|
await AppHost!.StopAsync();
|
|
base.OnExit(e);
|
|
}
|
|
|
|
}
|