/// <summary> /// Shows the tool window /// </summary> /// <returns>The tool window object if it is found.</returns> public static TToolWindow ShowToolWindow <TToolWindow>() where TToolWindow : ToolWindowPane { if (GoogleCloudExtensionPackage.Instance == null) { Debug.WriteLine("GoogleCloudExtensionPackage.Instance is null, unexpected error"); return(null); } // Get the instance number 0 of this tool window. This window is single instance so this instance // is actually the only one. // The last flag is set to true so that if the tool window does not exists it will be created. ToolWindowPane window = GoogleCloudExtensionPackage.Instance.FindToolWindow(typeof(TToolWindow), 0, true); ErrorHandlerUtils.HandleExceptions(() => { if (window?.Frame == null) { throw new NotSupportedException("Failed to create the tool window"); } IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show()); }); return(window as TToolWindow); }
/// <summary> /// Create empty solution at the <paramref name="localPath"/> /// </summary> /// <param name="localPath">Create the solution at the path.</param> /// <param name="name">The solution name.</param> public static void CreateEmptySolution(string localPath, string name) { localPath.ThrowIfNullOrEmpty(nameof(localPath)); var dte = Package.GetGlobalService(typeof(DTE)) as DTE2; try { dte.Solution.Create(localPath, name); dte.Solution.Close(false); } catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex)) { } }
/// <summary> /// Create empty solution at the <paramref name="localPath"/> /// </summary> /// <param name="localPath">Create the solution at the path.</param> /// <param name="name">The solution name.</param> public void CreateEmptySolution(string localPath, string name) { ThreadHelper.ThrowIfNotOnUIThread(); localPath.ThrowIfNullOrEmpty(nameof(localPath)); DTE2 dte = GoogleCloudExtensionPackage.Instance.Dte; try { dte.Solution.Create(localPath, name); dte.Solution.Close(false); } catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex)) { } }
/// <summary> /// Invokes the action handling all of the exceptions that escape the action. /// </summary> public void Invoke() { ErrorHandlerUtils.HandleExceptions(() => _action()); }
/// <summary> /// Safely executes the supplied action. /// </summary> public override void Execute(object _) => ErrorHandlerUtils.HandleExceptions(_action);
/// <summary> /// Invokes the task handling all of the exceptions that escape the task. /// </summary> public void Invoke() { ErrorHandlerUtils.HandleAsyncExceptions(_task); }