/// <summary> /// Uninstall a plugin, will return true if the program needs to restart to finish uninstalling. /// </summary> /// <param name="plugin"></param> /// <returns></returns> public bool uninstallPlugin(AtlasPlugin plugin, bool willReload) { bool needsRestart = false; String location = plugin.Location; if (plugin.AllowUninstall) { if (plugin.AllowRuntimeUninstall) { if (PluginUnloading != null) { PluginUnloading.Invoke(plugin); } unloadPlugin(plugin, willReload); try { File.Delete(location); } catch (Exception deleteEx) { Log.Error("Error deleting data file '{0}' from '{1}' because: {2}.", location, location, deleteEx.Message); managePluginInstructions.addFileToDelete(location); managePluginInstructions.savePersistantFile(); needsRestart = true; } } else { managePluginInstructions.addFileToDelete(location); managePluginInstructions.savePersistantFile(); needsRestart = true; } } return(needsRestart); }
private static void InvokeDeinitialize(Plugin plugin) { try { Debug.Write(LogType.Log, "Unloading plugin " + plugin); PluginUnloading?.Invoke(plugin); plugin.Deinitialize(); PluginUnloaded?.Invoke(plugin); } catch (Exception ex) { Debug.LogException(ex); Debug.LogErrorFormat("Failed to deinitialize plugin {0}. {1}", plugin, ex.Message); } }