/// <summary> /// Invokes SetEditLabel and checkes if the exception with the error message is caught. /// </summary> internal static bool CheckForSetEditLabelBadFileName <T>(HierarchyNode node, string badFileName, string expectedMessage) where T : Exception { bool badFileNameCaught = false; IVsExtensibility extensibility = node.GetService(typeof(IVsExtensibility)) as IVsExtensibility; extensibility.EnterAutomationFunction(); try { node.SetEditLabel(badFileName); } catch (Exception e) { if ((e is T) && (e.Message == expectedMessage || e.Message.Contains(expectedMessage))) { badFileNameCaught = true; } } finally { extensibility.ExitAutomationFunction(); } return(badFileNameCaught); }
private bool CheckForSaveAsOnBadFileName <T>(IServiceProvider sp, ProjectNode project, MethodInfo saveAs, string badFileName, string expectedMessage) where T : Exception { bool badFileNameCaught = false; IVsExtensibility extensibility = sp.GetService(typeof(IVsExtensibility)) as IVsExtensibility; extensibility.EnterAutomationFunction(); try { saveAs.Invoke(project, new object[] { badFileName }); } catch (Exception e) { if ((e.InnerException is T) && (e.InnerException.Message == expectedMessage || e.InnerException.Message.Contains(expectedMessage))) { badFileNameCaught = true; } } finally { extensibility.ExitAutomationFunction(); } return(badFileNameCaught); }
public override void EndBulkOperation() { try { _vsExtensibility.ExitAutomationFunction(); } catch { // If automation support isn't present it's not an issue } }