36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
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<ClientDataService>();
|
|
// ViewModels:
|
|
services.AddTransient<MainWindowViewModel>();
|
|
// Views:
|
|
services.AddSingleton<MainWindow>();
|
|
}).Build();
|
|
}
|
|
|
|
protected override async void OnStartup(StartupEventArgs e) {
|
|
await _host.StartAsync();
|
|
|
|
var window = _host.Services.GetRequiredService<MainWindow>();
|
|
window.Show();
|
|
|
|
base.OnStartup(e);
|
|
}
|
|
|
|
protected override async void OnExit(ExitEventArgs e) {
|
|
await _host.StopAsync();
|
|
_host.Dispose();
|
|
base.OnExit(e);
|
|
}
|
|
}
|
|
} |