|
|
|
|
@ -1,17 +1,42 @@ |
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Configuration; |
|
|
|
|
using System.Data; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
|
using Microsoft.Extensions.Hosting; |
|
|
|
|
using System.Windows; |
|
|
|
|
|
|
|
|
|
namespace MultiTerm.Wpf |
|
|
|
|
{ |
|
|
|
|
/// <summary> |
|
|
|
|
/// Interaction logic for App.xaml |
|
|
|
|
/// </summary> |
|
|
|
|
namespace MultiTerm.Wpf; |
|
|
|
|
|
|
|
|
|
public partial class App : Application |
|
|
|
|
{ |
|
|
|
|
public static IHost? AppHost { get; private set; } |
|
|
|
|
|
|
|
|
|
public App() |
|
|
|
|
{ |
|
|
|
|
// create dependency injection host |
|
|
|
|
AppHost = Host.CreateDefaultBuilder() |
|
|
|
|
.ConfigureServices((hostContext, services) => |
|
|
|
|
{ |
|
|
|
|
services.AddSingleton<MainWindow>(); |
|
|
|
|
|
|
|
|
|
// viewmodels |
|
|
|
|
//services.AddTransient<SendReceiveViewModel>(); |
|
|
|
|
}) |
|
|
|
|
.Build(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected override async void OnStartup(StartupEventArgs e) |
|
|
|
|
{ |
|
|
|
|
await AppHost!.StartAsync(); |
|
|
|
|
|
|
|
|
|
// instanciate startup form and show |
|
|
|
|
var startupForm = AppHost.Services.GetRequiredService<MainWindow>(); |
|
|
|
|
startupForm.Show(); |
|
|
|
|
|
|
|
|
|
base.OnStartup(e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected override async void OnExit(ExitEventArgs e) |
|
|
|
|
{ |
|
|
|
|
await AppHost!.StopAsync(); |
|
|
|
|
base.OnExit(e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|