/// <summary> /// Save a specific file in the Running Docuement Table. /// </summary> /// <param name="fileName"></param> public void saveRDTFile(string fileName) { IEnumRunningDocuments documents; if (DocumentTable != null) { DocumentTable.GetRunningDocumentsEnum(out documents); uint[] docCookie = new uint[1]; uint fetched; while ((VSConstants.S_OK == documents.Next(1, docCookie, out fetched)) && (1 == fetched)) { uint flags; uint editLocks; uint readLocks; string moniker; IVsHierarchy docHierarchy; uint docId; IntPtr docData = IntPtr.Zero; DocumentTable.GetDocumentInfo(docCookie[0], out flags, out readLocks, out editLocks, out moniker, out docHierarchy, out docId, out docData); if (fileName.Equals(moniker)) { DocumentTable.SaveDocuments((uint)__VSRDTSAVEOPTIONS.RDTSAVEOPT_ForceSave, null, 0, docCookie[0]); //FileLogger.DefaultLogger.Info("IVsRunningDocumentTable.SaveDocuments() DONE. [" + moniker + "]"); } } } }
internal override void Execute(EmacsCommandContext context) { IVsRunningDocumentTable service = context.Manager.ServiceProvider.GetService <SVsRunningDocumentTable, IVsRunningDocumentTable>(); if (service == null) { return; } service.SaveDocuments(1U, null, 4294967294U, 0U); }
public bool SaveDocument(IVsRunningDocumentTable rdt) { if (!IsDocumentInitialized || (_flags & _VSRDTFLAGS.RDT_DontSave) != 0) { return(true); } if (VSErr.Succeeded(rdt.SaveDocuments(0, Hierarchy, ItemId, Cookie))) { SetDirty(false); return(true); } return(false); }
private void VerifySolutionNaming() { ThreadHelper.ThrowIfNotOnUIThread(); IVsSolution sol = GetService <IVsSolution>(typeof(SVsSolution)); string dir, path, user; if (sol == null || !VSErr.Succeeded(sol.GetSolutionInfo(out dir, out path, out user)) || string.IsNullOrEmpty(path)) { return; } string trueSln = SvnTools.GetTruePath(path, true) ?? SvnTools.GetNormalizedFullPath(path); if (trueSln == path) { return; // Nothing to do for us } IVsRunningDocumentTable rdt = GetService <IVsRunningDocumentTable>(typeof(SVsRunningDocumentTable)); if (rdt == null) { return; } Guid IID_hier = typeof(IVsHierarchy).GUID; IntPtr hier = IntPtr.Zero; IntPtr unk = Marshal.GetIUnknownForObject(sol); IntPtr ppunkDocData = IntPtr.Zero; try { IVsHierarchy slnHier; uint pitemid; uint pdwCookie; if (!VSErr.Succeeded(rdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_EditLock, path, out slnHier, out pitemid, out ppunkDocData, out pdwCookie))) { return; } if (!VSErr.Succeeded(Marshal.QueryInterface(unk, ref IID_hier, out hier))) { hier = IntPtr.Zero; return; } if (VSErr.Succeeded(rdt.RenameDocument(path, trueSln, hier, VSItemId.Root))) { int hr; hr = rdt.SaveDocuments((uint)(__VSRDTSAVEOPTIONS.RDTSAVEOPT_ForceSave | __VSRDTSAVEOPTIONS.RDTSAVEOPT_SaveNoChildren), slnHier, pitemid, pdwCookie); hr = sol.SaveSolutionElement((uint)(__VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave), (IVsHierarchy)sol, pdwCookie); //GC.KeepAlive(hr); } if (ppunkDocData != IntPtr.Zero) { object doc = Marshal.GetObjectForIUnknown(ppunkDocData); } } finally { System.Runtime.InteropServices.Marshal.Release(unk); if (hier != IntPtr.Zero) { System.Runtime.InteropServices.Marshal.Release(hier); } if (ppunkDocData != IntPtr.Zero) { Marshal.Release(hier); } } }
internal bool SaveDocument(IVsRunningDocumentTable rdt) { if (ErrorHandler.Succeeded(rdt.SaveDocuments(0, Hierarchy, ItemId, Cookie))) { SetDirty(false); return true; } return false; }