LANCommander/LANCommander.Playnite.Extension/UninstallController.cs

43 lines
1.2 KiB
C#
Raw Normal View History

2023-04-07 19:09:00 -05:00
using LANCommander.SDK.Enums;
2023-08-21 18:44:20 -05:00
using Playnite.SDK;
2023-01-07 12:46:26 -06:00
using Playnite.SDK.Models;
using Playnite.SDK.Plugins;
using System;
using System.IO;
namespace LANCommander.PlaynitePlugin
2023-01-07 12:46:26 -06:00
{
public class LANCommanderUninstallController : UninstallController
{
2023-08-21 18:44:20 -05:00
public static readonly ILogger Logger = LogManager.GetLogger();
private LANCommanderLibraryPlugin Plugin;
private PowerShellRuntime PowerShellRuntime;
2023-01-07 12:46:26 -06:00
public LANCommanderUninstallController(LANCommanderLibraryPlugin plugin, Game game) : base(game)
2023-01-07 12:46:26 -06:00
{
Name = "Uninstall LANCommander Game";
Plugin = plugin;
PowerShellRuntime = new PowerShellRuntime();
2023-01-07 12:46:26 -06:00
}
public override void Uninstall(UninstallActionArgs args)
{
try
{
PowerShellRuntime.RunScript(Game, ScriptType.Uninstall);
}
catch { }
2023-08-21 18:44:20 -05: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 12:46:26 -06:00
2023-08-21 18:44:20 -05:00
Logger.Trace("Deleted!");
2023-01-07 12:46:26 -06:00
InvokeOnUninstalled(new GameUninstalledEventArgs());
}
}
}