Add project files.
This commit is contained in:
42
WinGreedWPF/App.xaml.cs
Normal file
42
WinGreedWPF/App.xaml.cs
Normal file
@ -0,0 +1,42 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user