Microsoft.VsSDK.IntegrationTestLibrary.TestUtils.SaveDocument C# (CSharp) Method

SaveDocument() public method

Save an open document.
public SaveDocument ( string documentMoniker ) : void
documentMoniker string for filebased documents this is the full path to the document
return void
        public void SaveDocument(string documentMoniker)
        {
            // Get document cookie and hierarchy for the file
            IVsRunningDocumentTable runningDocumentTableService = (IVsRunningDocumentTable)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsRunningDocumentTable));
            uint docCookie;
            IntPtr docData;
            IVsHierarchy hierarchy;
            uint itemId;
            runningDocumentTableService.FindAndLockDocument(
                (uint)Microsoft.VisualStudio.Shell.Interop._VSRDTFLAGS.RDT_NoLock,
                documentMoniker,
                out hierarchy,
                out itemId,
                out docData,
                out docCookie);

            // Save the document
            IVsSolution solutionService = (IVsSolution)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsSolution));
            solutionService.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave, hierarchy, docCookie);
        }