Re-add file association

This commit is contained in:
erri120
2022-10-16 14:00:50 +02:00
parent e37911e4e7
commit 5a8383d12f
4 changed files with 13 additions and 29 deletions

View File

@ -9,6 +9,7 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using NLog.Targets;
using Orc.FileAssociation;
using ReactiveUI;
using Wabbajack.CLI.Builder;
using Wabbajack.DTOs;
@ -108,6 +109,9 @@ namespace Wabbajack
{
services.AddOSIntegrated();
// Orc.FileAssociation
services.AddSingleton<IApplicationRegistrationService>(new ApplicationRegistrationService());
services.AddSingleton<CefService>();
services.AddSingleton<IUserInterventionHandler, UserIntreventionHandler>();
@ -147,7 +151,6 @@ namespace Wabbajack
return services;
}
private void OnExit(object sender, ExitEventArgs e)
{
using (_host)

View File

@ -14,6 +14,7 @@ using System.Windows;
using System.Windows.Input;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Orc.FileAssociation;
using Wabbajack.Common;
using Wabbajack.Downloaders.GameFile;
using Wabbajack;
@ -143,6 +144,13 @@ namespace Wabbajack
Task.Run(() => _wjClient.SendMetric("started_wabbajack", fvi.FileVersion)).FireAndForget();
Task.Run(() => _wjClient.SendMetric("started_sha", ThisAssembly.Git.Sha));
// setup file association
var applicationRegistrationService = _serviceProvider.GetRequiredService<IApplicationRegistrationService>();
var applicationInfo = new ApplicationInfo(assembly);
applicationInfo.SupportedExtensions.Add("wabbajack");
applicationRegistrationService.RegisterApplication(applicationInfo);
}
catch (Exception ex)
{

View File

@ -143,34 +143,6 @@ namespace Wabbajack
_settings = settings;
}
/// <summary>
/// Starts some background initialization tasks spinning so they're already prepped when actually needed
/// </summary>
private void Warmup()
{
Task.Run(AssociateListsWithWabbajack).FireAndForget();
}
/// <summary>
/// Run logic to associate wabbajack lists with this app in the background
/// </summary>
private void AssociateListsWithWabbajack()
{
/* TODO
var appPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
try
{
if (!ModListAssociationManager.IsAssociated() || ModListAssociationManager.NeedsUpdating(appPath))
{
ModListAssociationManager.Associate(appPath);
}
}
catch (Exception e)
{
Utils.Log($"ExtensionManager had an exception:\n{e}");
}*/
}
private void RunWhenLoaded(Action a)
{
if (IsLoaded)

View File

@ -93,6 +93,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1343.22" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.0.4" />
<PackageReference Include="Orc.FileAssociation" Version="4.4.1" />
<PackageReference Include="PInvoke.User32" Version="0.7.124" />
<PackageReference Include="ReactiveUI" Version="18.3.1" />
<PackageReference Include="ReactiveUI.Fody" Version="18.3.1" />