2021-12-26 21:56:44 +00:00
|
|
|
|
using System;
|
2021-12-30 04:43:31 +00:00
|
|
|
|
using System.Reactive.Concurrency;
|
|
|
|
|
using System.Reactive.Disposables;
|
2021-12-26 21:56:44 +00:00
|
|
|
|
using System.Windows;
|
2021-12-30 04:43:31 +00:00
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
using CefSharp.DevTools.Debugger;
|
2021-12-27 05:13:28 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2021-12-28 21:39:20 +00:00
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2021-12-30 04:43:31 +00:00
|
|
|
|
using ReactiveUI;
|
|
|
|
|
using Splat;
|
2021-12-26 21:56:44 +00:00
|
|
|
|
using Wabbajack.Common;
|
2021-12-30 00:15:37 +00:00
|
|
|
|
using Wabbajack;
|
2021-12-27 05:13:28 +00:00
|
|
|
|
using Wabbajack.Services.OSIntegrated;
|
2021-12-28 21:39:20 +00:00
|
|
|
|
using Wabbajack.Util;
|
2021-12-26 21:56:44 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for App.xaml
|
|
|
|
|
/// </summary>
|
2021-12-27 05:13:28 +00:00
|
|
|
|
public partial class App
|
2021-12-26 21:56:44 +00:00
|
|
|
|
{
|
2021-12-28 21:39:20 +00:00
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
2021-12-30 04:43:31 +00:00
|
|
|
|
private readonly IHost _host;
|
|
|
|
|
|
2021-12-26 21:56:44 +00:00
|
|
|
|
public App()
|
|
|
|
|
{
|
2021-12-30 04:43:31 +00:00
|
|
|
|
_host = Host.CreateDefaultBuilder(Array.Empty<string>())
|
|
|
|
|
.ConfigureLogging(c =>
|
|
|
|
|
{
|
|
|
|
|
c.ClearProviders();
|
|
|
|
|
})
|
|
|
|
|
.ConfigureServices((host, services) =>
|
|
|
|
|
{
|
|
|
|
|
ConfigureServices(services);
|
|
|
|
|
})
|
|
|
|
|
.Build();
|
2021-12-28 21:39:20 +00:00
|
|
|
|
|
2021-12-30 04:43:31 +00:00
|
|
|
|
_serviceProvider = _host.Services;
|
2021-12-27 05:13:28 +00:00
|
|
|
|
}
|
2021-12-28 21:39:20 +00:00
|
|
|
|
private IServiceCollection ConfigureServices(IServiceCollection services)
|
2021-12-27 05:13:28 +00:00
|
|
|
|
{
|
2021-12-30 04:43:31 +00:00
|
|
|
|
RxApp.MainThreadScheduler = new DispatcherScheduler(Dispatcher.CurrentDispatcher);
|
|
|
|
|
|
2021-12-27 05:13:28 +00:00
|
|
|
|
services.AddOSIntegrated();
|
2021-12-28 21:39:20 +00:00
|
|
|
|
services.AddTransient<MainWindow>();
|
|
|
|
|
services.AddTransient<MainWindowVM>();
|
|
|
|
|
services.AddSingleton<SystemParametersConstructor>();
|
|
|
|
|
services.AddSingleton<LauncherUpdater>();
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<MainSettings>();
|
|
|
|
|
services.AddTransient<CompilerVM>();
|
|
|
|
|
services.AddTransient<InstallerVM>();
|
2021-12-29 17:26:12 +00:00
|
|
|
|
services.AddTransient<ModeSelectionVM>();
|
|
|
|
|
services.AddTransient<ModListGalleryVM>();
|
2021-12-28 21:39:20 +00:00
|
|
|
|
|
|
|
|
|
return services;
|
2021-12-27 05:13:28 +00:00
|
|
|
|
}
|
|
|
|
|
private void OnStartup(object sender, StartupEventArgs e)
|
|
|
|
|
{
|
2021-12-30 04:43:31 +00:00
|
|
|
|
RxApp.MainThreadScheduler.Schedule(0, (_, _) =>
|
|
|
|
|
{
|
|
|
|
|
var mainWindow = _serviceProvider.GetRequiredService<MainWindow>();
|
|
|
|
|
mainWindow!.Show();
|
|
|
|
|
return Disposable.Empty;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnExit(object sender, ExitEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (_host)
|
|
|
|
|
{
|
|
|
|
|
_host.StopAsync();
|
|
|
|
|
}
|
|
|
|
|
base.OnExit(e);
|
2021-12-26 21:56:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|