using System.Windows; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using ClientApiPoC.OnPremiseApp.Services; namespace ClientApiPoC.OnPremiseApp { public partial class App : Application { private IHost _host; public App() { _host = Host.CreateDefaultBuilder().ConfigureServices(services => { // Services: services.AddSingleton(); // ViewModels: services.AddTransient(); // Views: services.AddSingleton(); }).Build(); } protected override async void OnStartup(StartupEventArgs e) { await _host.StartAsync(); var window = _host.Services.GetRequiredService(); window.Show(); base.OnStartup(e); } protected override async void OnExit(ExitEventArgs e) { await _host.StopAsync(); _host.Dispose(); base.OnExit(e); } } }