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