LANCommander/LANCommander.Playnite.Exten.../UninstallController.cs

43 lines
1.2 KiB
C#
Raw Permalink Normal View History

2023-04-08 00:09:00 +00:00
using LANCommander.SDK.Enums;
2023-08-21 23:44:20 +00:00
using Playnite.SDK;
2023-01-07 18:46:26 +00:00
using Playnite.SDK.Models;
using Playnite.SDK.Plugins;
using System;
using System.IO;
namespace LANCommander.PlaynitePlugin
2023-01-07 18:46:26 +00:00
{
public class LANCommanderUninstallController : UninstallController
{
2023-08-21 23:44:20 +00:00
public static readonly ILogger Logger = LogManager.GetLogger();
private LANCommanderLibraryPlugin Plugin;
private PowerShellRuntime PowerShellRuntime;
2023-01-07 18:46:26 +00:00
public LANCommanderUninstallController(LANCommanderLibraryPlugin plugin, Game game) : base(game)
2023-01-07 18:46:26 +00:00
{
Name = "Uninstall LANCommander Game";
Plugin = plugin;
PowerShellRuntime = new PowerShellRuntime();
2023-01-07 18:46:26 +00:00
}
public override void Uninstall(UninstallActionArgs args)
{
try
{
PowerShellRuntime.RunScript(Game, ScriptType.Uninstall);
}
catch { }
2023-08-21 23:44:20 +00:00
Logger.Trace("Attempting to delete install directory...");
if (!String.IsNullOrWhiteSpace(Game.InstallDirectory) && Directory.Exists(Game.InstallDirectory))
Directory.Delete(Game.InstallDirectory, true);
2023-01-07 18:46:26 +00:00
2023-08-21 23:44:20 +00:00
Logger.Trace("Deleted!");
2023-01-07 18:46:26 +00:00
InvokeOnUninstalled(new GameUninstalledEventArgs());
}
}
}