2022-03-13 22:47:30 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Reactive.Concurrency;
|
|
|
|
|
using System.Reactive.Disposables;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using ReactiveUI;
|
|
|
|
|
using Wabbajack.DTOs;
|
2022-05-16 22:14:52 +00:00
|
|
|
|
using Wabbajack.DTOs.Interventions;
|
|
|
|
|
using Wabbajack.Interventions;
|
2022-03-13 22:47:30 +00:00
|
|
|
|
using Wabbajack.LoginManagers;
|
|
|
|
|
using Wabbajack.Models;
|
|
|
|
|
using Wabbajack.Services.OSIntegrated;
|
|
|
|
|
using Wabbajack.UserIntervention;
|
|
|
|
|
using Wabbajack.Util;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for App.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class App
|
|
|
|
|
{
|
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
|
private readonly IHost _host;
|
|
|
|
|
|
|
|
|
|
public App()
|
|
|
|
|
{
|
|
|
|
|
_host = Host.CreateDefaultBuilder(Array.Empty<string>())
|
|
|
|
|
.ConfigureLogging(c =>
|
|
|
|
|
{
|
|
|
|
|
c.ClearProviders();
|
|
|
|
|
})
|
|
|
|
|
.ConfigureServices((host, services) =>
|
|
|
|
|
{
|
|
|
|
|
ConfigureServices(services);
|
|
|
|
|
})
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
_serviceProvider = _host.Services;
|
|
|
|
|
}
|
|
|
|
|
private static IServiceCollection ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
RxApp.MainThreadScheduler = new DispatcherScheduler(Dispatcher.CurrentDispatcher);
|
|
|
|
|
|
|
|
|
|
services.AddOSIntegrated();
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<CefService>();
|
2022-05-21 21:11:43 +00:00
|
|
|
|
services.AddSingleton<IUserInterventionHandler, UserIntreventionHandler>();
|
2022-03-13 22:47:30 +00:00
|
|
|
|
|
|
|
|
|
services.AddTransient<MainWindow>();
|
|
|
|
|
services.AddTransient<MainWindowVM>();
|
2022-05-20 04:12:16 +00:00
|
|
|
|
services.AddTransient<BrowserWindow>();
|
2022-03-13 22:47:30 +00:00
|
|
|
|
services.AddSingleton<SystemParametersConstructor>();
|
|
|
|
|
services.AddSingleton<LauncherUpdater>();
|
|
|
|
|
services.AddSingleton<ResourceMonitor>();
|
|
|
|
|
services.AddAllSingleton<ILoggerProvider, LoggerProvider>();
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<MainSettings>();
|
|
|
|
|
services.AddTransient<CompilerVM>();
|
|
|
|
|
services.AddTransient<InstallerVM>();
|
|
|
|
|
services.AddTransient<ModeSelectionVM>();
|
|
|
|
|
services.AddTransient<ModListGalleryVM>();
|
|
|
|
|
services.AddTransient<CompilerVM>();
|
|
|
|
|
services.AddTransient<InstallerVM>();
|
|
|
|
|
services.AddTransient<SettingsVM>();
|
|
|
|
|
services.AddTransient<WebBrowserVM>();
|
|
|
|
|
|
|
|
|
|
// Login Handlers
|
|
|
|
|
services.AddTransient<VectorPlexusLoginHandler>();
|
|
|
|
|
services.AddTransient<NexusLoginHandler>();
|
|
|
|
|
services.AddTransient<LoversLabLoginHandler>();
|
|
|
|
|
|
|
|
|
|
// Login Managers
|
|
|
|
|
services.AddAllSingleton<INeedsLogin, LoversLabLoginManager>();
|
|
|
|
|
services.AddAllSingleton<INeedsLogin, NexusLoginManager>();
|
|
|
|
|
services.AddAllSingleton<INeedsLogin, VectorPlexusLoginManager>();
|
2022-05-16 22:14:52 +00:00
|
|
|
|
services.AddSingleton<ManualDownloadHandler>();
|
2022-05-19 03:21:38 +00:00
|
|
|
|
services.AddSingleton<ManualBlobDownloadHandler>();
|
2022-03-13 22:47:30 +00:00
|
|
|
|
|
|
|
|
|
return services;
|
|
|
|
|
}
|
|
|
|
|
private void OnStartup(object sender, StartupEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|