/// <summary> /// Handles "Batch inline on document" command from code context menu. /// </summary> private void BatchInlineCodeClick(object sender, EventArgs args) { try { if (OperationInProgress) { throw new Exception("Cannot start operation 'Batch inline', because another operation is in progress."); } OperationInProgress = true; batchInlineCommand.Process(true); BatchInlineToolWindow win = ShowToolWindow <BatchInlineToolWindow>(); if (win != null) { win.SetData(batchInlineCommand.Results); } else { throw new Exception("Unable to display tool window."); } batchInlineCommand.Results.Clear(); } catch (Exception ex) { if (OperationInProgress) { VLDocumentViewsManager.ReleaseLocks(); } VLDocumentViewsManager.CloseInvisibleWindows(typeof(BatchInlineCommand), false); VLOutputWindow.VisualLocalizerPane.WriteException(ex); MessageBox.ShowException(ex); OperationInProgress = false; } }
public void ProcessTest() { Agent.EnsureSolutionOpen(); DTE2 DTE = Agent.GetDTE(); BatchInlineCommand target = Agent.BatchInlineCommand; var window = DTE.OpenFile(null, Agent.AspNetReferencesTestFile1); window.Activate(); target.Process(true); Assert.IsTrue(VLDocumentViewsManager.IsFileLocked(Agent.AspNetReferencesTestFile1)); ValidateResults(GetExpectedResultsFor(Agent.AspNetReferencesTestFile1), target.Results); Assert.IsTrue(VLDocumentViewsManager.IsFileLocked(Agent.AspNetReferencesTestFile1)); VLDocumentViewsManager.ReleaseLocks(); Assert.IsFalse(VLDocumentViewsManager.IsFileLocked(Agent.AspNetReferencesTestFile1)); window.Detach(); window.Close(EnvDTE.vsSaveChanges.vsSaveChangesNo); }