protected virtual void LockRDTEntry() { // Define flags for the nested project document _VSRDTFLAGS flags = _VSRDTFLAGS.RDT_VirtualDocument | _VSRDTFLAGS.RDT_ProjSlnDocument;; // Request the RDT service IVsRunningDocumentTable rdt = this.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; Debug.Assert(rdt != null, " Could not get running document table from the services exposed by this project"); if (rdt == null) { throw new InvalidOperationException(); } // First we see if someone else has opened the requested view of the file. uint itemid; IntPtr docData = IntPtr.Zero; IVsHierarchy ivsHierarchy; uint docCookie; IntPtr projectPtr = IntPtr.Zero; try { ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)flags, this.projectPath, out ivsHierarchy, out itemid, out docData, out docCookie)); flags |= _VSRDTFLAGS.RDT_EditLock; if (ivsHierarchy != null && docCookie != (uint)ShellConstants.VSDOCCOOKIE_NIL) { if (docCookie != this.DocCookie) { this.DocCookie = docCookie; } } else { // get inptr for hierarchy projectPtr = Marshal.GetIUnknownForObject(this.nestedHierarchy); Debug.Assert(projectPtr != IntPtr.Zero, " Project pointer for the nested hierarchy has not been initialized"); ErrorHandler.ThrowOnFailure(rdt.RegisterAndLockDocument((uint)flags, this.projectPath, this.ProjectMgr, this.ID, projectPtr, out docCookie)); this.DocCookie = docCookie; Debug.Assert(this.DocCookie != (uint)ShellConstants.VSDOCCOOKIE_NIL, "Invalid cookie when registering document in the running document table."); //we must also set the doc cookie on the nested hier this.SetDocCookieOnNestedHier(this.DocCookie); } } finally { // Release all Inptr's that that were given as out pointers if (docData != IntPtr.Zero) { Marshal.Release(docData); } if (projectPtr != IntPtr.Zero) { Marshal.Release(projectPtr); } } }
public uint RegisterAndLockDocument(_VSRDTFLAGS lockType, string mkDocument, IVsHierarchy hierarchy, uint itemid, IntPtr docData) { uint cookie; NativeMethods.ThrowOnFailure(rdt.RegisterAndLockDocument((uint)lockType, mkDocument, hierarchy, itemid, docData, out cookie)); return(cookie); }
public SessionNode(SessionsNode parent, ProfilingTarget target, string filename) { _parent = parent; _target = target; _filename = filename; // Register this with the running document table. This will prompt for save when the file is dirty and // by responding to GetProperty for VSHPROPID_ItemDocCookie we will support Ctrl-S when one of our // files is dirty. // http://msdn.microsoft.com/en-us/library/bb164600(VS.80).aspx IVsRunningDocumentTable rdt = NodejsProfilingPackage.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; uint cookie; IntPtr punkDocData = Marshal.GetIUnknownForObject(this); try { ErrorHandler.ThrowOnFailure(rdt.RegisterAndLockDocument((uint)(_VSRDTFLAGS.RDT_VirtualDocument | _VSRDTFLAGS.RDT_EditLock | _VSRDTFLAGS.RDT_CanBuildFromMemory), filename, this, VSConstants.VSITEMID_ROOT, punkDocData, out cookie)); } finally { if (punkDocData != IntPtr.Zero) { Marshal.Release(punkDocData); } } _docCookie = cookie; ItemId = parent._sessionsCollection.Add(this); }
public static RunningDocumentInfo RegisterAndLockDocument(RdtLocks lockType, string mkDocument, IVsHierarchy hierarchy, uint itemid, IntPtr docData) { uint cookie; NativeMethods.ThrowOnFailure(_Rdt.RegisterAndLockDocument((uint)lockType, mkDocument, hierarchy, itemid, docData, out cookie)); return(GetDocumentInfo(cookie)); }