From 2b33aeb7d98b8d26fef6b9c38a714c16e3c6b890 Mon Sep 17 00:00:00 2001 From: Halgari Date: Fri, 14 Oct 2022 15:11:09 -0600 Subject: [PATCH] Refactor WPF startup to accept commandline inputs --- Wabbajack.App.Wpf/App.xaml.cs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Wabbajack.App.Wpf/App.xaml.cs b/Wabbajack.App.Wpf/App.xaml.cs index cceecbb0..b96cae08 100644 --- a/Wabbajack.App.Wpf/App.xaml.cs +++ b/Wabbajack.App.Wpf/App.xaml.cs @@ -27,15 +27,14 @@ namespace Wabbajack /// public partial class App { - private readonly IServiceProvider _serviceProvider; - private readonly IHost _host; + private IHost _host; - public App() + private void OnStartup(object sender, StartupEventArgs e) { WebView2AutoInstaller.CheckAndInstallAsync(false, false).Wait(); RxApp.MainThreadScheduler = new DispatcherScheduler(Dispatcher.CurrentDispatcher); - _host = Host.CreateDefaultBuilder(Array.Empty()) + _host = Host.CreateDefaultBuilder(e.Args) .ConfigureLogging(AddLogging) .ConfigureServices((host, services) => { @@ -43,7 +42,12 @@ namespace Wabbajack }) .Build(); - _serviceProvider = _host.Services; + RxApp.MainThreadScheduler.Schedule(0, (_, _) => + { + var mainWindow = _host.Services.GetRequiredService(); + mainWindow!.Show(); + return Disposable.Empty; + }); } private void AddLogging(ILoggingBuilder loggingBuilder) @@ -121,15 +125,7 @@ namespace Wabbajack return services; } - private void OnStartup(object sender, StartupEventArgs e) - { - RxApp.MainThreadScheduler.Schedule(0, (_, _) => - { - var mainWindow = _serviceProvider.GetRequiredService(); - mainWindow!.Show(); - return Disposable.Empty; - }); - } + private void OnExit(object sender, ExitEventArgs e) {