/// <summary> /// Called by the base when one of our menu ids is queried for. If the index is /// is greater than the count we want to return false /// </summary> public override bool QueryStatusCommand(int cmdIndex, EventArgs e) { IActiveDebugFrameworkServices activeDebugFramework = StartupProjectHelper.GetExportFromSingleDotNetStartupProject <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles); if (activeDebugFramework != null) { // See if this project supports at least two runtimes List <string> frameworks = null; string activeFramework = null; ExecuteSynchronously(async() => { frameworks = await activeDebugFramework.GetProjectFrameworksAsync().ConfigureAwait(false); if (frameworks != null && frameworks.Count > 1 && cmdIndex < frameworks.Count) { // Only call this if we will need it down below. activeFramework = await activeDebugFramework.GetActiveDebuggingFrameworkPropertyAsync().ConfigureAwait(false); } }); if (frameworks == null || frameworks.Count < 2) { // Hide and disable the command Visible = false; Enabled = false; Checked = false; return(true); } else if (cmdIndex >= 0 && cmdIndex < frameworks.Count) { Text = frameworks[cmdIndex]; Visible = true; Enabled = true; // Get's a check if it matches the active one, or there is no active one in which case the first one is the active one Checked = (string.IsNullOrEmpty(activeFramework) && cmdIndex == 0) || string.Equals(frameworks[cmdIndex], activeFramework, StringComparison.Ordinal); MatchedCommandId = 0; return(true); } } return(false); }
/// <summary> /// CAlled by the base when one if our menu ids is clicked. Need to return true if the command was handled /// </summary> public override bool ExecCommand(int cmdIndex, EventArgs e) { bool handled = false; IActiveDebugFrameworkServices activeDebugFramework = StartupProjectHelper.GetExportFromSingleDotNetStartupProject <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles); if (activeDebugFramework != null) { ExecuteSynchronously(async() => { List <string> frameworks = await activeDebugFramework.GetProjectFrameworksAsync().ConfigureAwait(false); if (frameworks != null && cmdIndex >= 0 && cmdIndex < frameworks.Count) { await activeDebugFramework.SetActiveDebuggingFrameworkPropertyAsync(frameworks[cmdIndex]).ConfigureAwait(false); handled = true; } }); } return(handled); }
public void QueryStatus() { IActiveDebugFrameworkServices activeDebugFramework = StartupProjectHelper.GetExportFromSingleDotNetStartupProject <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles); if (activeDebugFramework != null) { string activeFramework = null; List <string> frameworks = null; ExecuteSynchronously(async() => { frameworks = await activeDebugFramework.GetProjectFrameworksAsync(); if (frameworks != null && frameworks.Count > 1) { // Only get this if we will need it down below activeFramework = await activeDebugFramework.GetActiveDebuggingFrameworkPropertyAsync(); } }); if (frameworks != null && frameworks.Count > 1) { // If no active framework or the current active property doesn't match any of the frameworks, then // st it to the first one. if (!string.IsNullOrEmpty(activeFramework) && frameworks.Contains(activeFramework)) { Text = string.Format(VSResources.DebugFrameworkMenuText, activeFramework); } else { Text = string.Format(VSResources.DebugFrameworkMenuText, frameworks[0]); } Visible = true; Enabled = true; } } }