/// <summary>Toggle the enabled status of plugin <paramref name="pluginInstance" /></summary> /// <param name="pluginInstance">The plugin to enable or disable</param> /// <returns></returns> private async Task PluginEnableDisableAsync(PluginInstance pluginInstance) { if (_ignoreEnabledChanged) { _ignoreEnabledChanged = false; return; } if (pluginInstance.Metadata.Enabled) { return; } if (pluginInstance.Status != PluginStatus.Stopped) { if (await PromptUserConfirmationAsync($"{pluginInstance.Metadata.DisplayName} will be stopped. Continue ?").ConfigureAwait(true) == false) { _ignoreEnabledChanged = true; pluginInstance.Metadata.Enabled = true; return; } await PluginMgr.StopPlugin(pluginInstance).ConfigureAwait(true); } pluginInstance.Metadata.Enabled = false; }
/// <summary>Starts or stops <paramref name="pluginInstance" /> depending on its current status</summary> /// <param name="pluginInstance"></param> /// <param name="attachDebugger"></param> /// <returns></returns> private Task PluginPlayPauseAsync(PluginInstance pluginInstance, bool attachDebugger) { switch (pluginInstance.Status) { case PluginStatus.Stopped: return(PluginMgr.StartPlugin(pluginInstance, attachDebugger)); case PluginStatus.Connected: return(PluginMgr.StopPlugin(pluginInstance)); default: throw new InvalidOperationException($"Invalid plugin status {pluginInstance.Status}"); } }