test/Misc/EFTools/TestInfrastructure/VS/DteExtensions.cs
/// <summary>
///     Executes the specified command for the open document.
/// </summary>
Executes the specified command for the open document.
Executes the specified command for the open document .
public static void ExecuteCommandForOpenDocument(this DTE dte, string fullFilePath, string command)
        {
            Debug.Assert(dte != null, "dte must not be null.");
            Debug.Assert(!string.IsNullOrWhiteSpace(fullFilePath), "fullFilePath must not be null or emtpy string.");
            var serviceProvider = new ServiceProvider((IServiceProvider)dte);
            IVsUIHierarchy hierarchy;
            uint itemId;
            IVsWindowFrame windowFrame;
            if (VsShellUtilities.IsDocumentOpen(serviceProvider, fullFilePath, Guid.Empty, out hierarchy, out itemId, out windowFrame))
            {
                windowFrame.Show();
                dte.ExecuteCommand(command, "");
            }
            else
            {
                throw new InvalidOperationException(
                    string.Format("Executing command '{0}' failed. Document '{1}' not open.", command, fullFilePath));
            }
        }
public static void ExecuteCommandForOpenDocument ( this DTE dte , string fullFilePath , string command ) { Debug . Assert ( dte != null , " " ) ; Debug . Assert ( ! string . IsNullOrWhiteSpace ( fullFilePath ) , " " ) ; var serviceProvider = new ServiceProvider ( ( IServiceProvider ) dte ) ; IVsUIHierarchy hierarchy ; uint itemId ; IVsWindowFrame windowFrame ; if ( VsShellUtilities . IsDocumentOpen ( serviceProvider , fullFilePath , Guid . Empty , out hierarchy , out itemId , out windowFrame ) ) { windowFrame . Show ( ) ; dte . ExecuteCommand ( command , " " ) ; } else { throw new InvalidOperationException ( string . Format ( " " , command , fullFilePath ) ) ; } }
Executes the specified command for the open document.
Executes the specified command for the open document .
DTE
this
fullFilePath
string
command
string