internal static bool IsDirty(IVsPersistDocData docData) { int pfDirty; ErrorHandler.ThrowOnFailure(docData.IsDocDataDirty(out pfDirty)); return(pfDirty > 0); }
public static bool IsDocumentDirty(string documentPath, out IVsPersistDocData persistDocData) { var serviceProvider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_dte); IVsHierarchy vsHierarchy; uint itemId, docCookie; VsShellUtilities.GetRDTDocumentInfo( serviceProvider, documentPath, out vsHierarchy, out itemId, out persistDocData, out docCookie); if (persistDocData != null) { int isDirty; persistDocData.IsDocDataDirty(out isDirty); return isDirty == 1; } return false; }
public static bool IsDocumentDirty(string documentPath, out IVsPersistDocData persistDocData) { var serviceProvider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_dte); IVsHierarchy vsHierarchy; uint itemId, docCookie; VsShellUtilities.GetRDTDocumentInfo( serviceProvider, documentPath, out vsHierarchy, out itemId, out persistDocData, out docCookie); if (persistDocData != null) { int isDirty; persistDocData.IsDocDataDirty(out isDirty); return(isDirty == 1); } return(false); }
/// <summary> /// Get document properties from RDT /// </summary> private void GetDocInfo( out bool isOpen, // true if the doc is opened out bool isDirty, // true if the doc is dirty out bool isOpenedByUs, // true if opened by our project out uint docCookie, // VSDOCCOOKIE if open out IVsPersistDocData persistDocData) { isOpen = isDirty = isOpenedByUs = false; docCookie = (uint)ShellConstants.VSDOCCOOKIE_NIL; persistDocData = null; if (this.node == null || this.node.ProjectMgr == null || this.node.ProjectMgr.IsClosed) { return; } IVsHierarchy hierarchy; uint vsitemid = VSConstants.VSITEMID_NIL; VsShellUtilities.GetRDTDocumentInfo(this.node.ProjectMgr.Site, this.node.Url, out hierarchy, out vsitemid, out persistDocData, out docCookie); if (hierarchy == null || docCookie == (uint)ShellConstants.VSDOCCOOKIE_NIL) { return; } isOpen = true; // check if the doc is opened by another project if (Utilities.IsSameComObject(this.node.ProjectMgr, hierarchy)) { isOpenedByUs = true; } if (persistDocData != null) { int isDocDataDirty; ErrorHandler.ThrowOnFailure(persistDocData.IsDocDataDirty(out isDocDataDirty)); isDirty = (isDocDataDirty != 0); } }
/// <summary> /// Get document properties from RDT /// </summary> public virtual void GetDocInfo( out bool isOpen, // true if the doc is opened out bool isDirty, // true if the doc is dirty out bool isOpenedByUs, // true if opened by our project out uint docCookie, // VSDOCCOOKIE if open out IVsPersistDocData persistDocData) { isOpen = isDirty = isOpenedByUs = false; docCookie = (uint)ShellConstants.VSDOCCOOKIE_NIL; persistDocData = null; if(this.node == null || this.node.ProjectManager == null || this.node.ProjectManager.IsClosed) { return; } IVsHierarchy hierarchy; uint vsitemid = VSConstants.VSITEMID_NIL; VsShellUtilities.GetRDTDocumentInfo(this.node.ProjectManager.Site, this.node.Url, out hierarchy, out vsitemid, out persistDocData, out docCookie); if(hierarchy == null || docCookie == (uint)ShellConstants.VSDOCCOOKIE_NIL) { return; } isOpen = true; // check if the doc is opened by another project if(Utilities.IsSameComObject(this.node.ProjectManager.InteropSafeIVsHierarchy, hierarchy)) { isOpenedByUs = true; } if(persistDocData != null) { int isDocDataDirty; ErrorHandler.ThrowOnFailure(persistDocData.IsDocDataDirty(out isDocDataDirty)); isDirty = (isDocDataDirty != 0); } }
// File node properties. void GetDocInfo(out bool pfOpen, // true if the doc is opened out bool pfDirty, // true if the doc is dirty out bool pfOpenByUs, // true if opened by our project out uint pVsDocCookie, out IVsPersistDocData ppIVsPersistDocData){// VSDOCCOOKIE if open pfOpen = pfDirty = pfOpenByUs = false; pVsDocCookie = VsConstants.VSDOCCOOKIE_NIL; IVsHierarchy srpIVsHierarchy; uint vsitemid = VsConstants.VSITEMID_NIL; GetRDTDocumentInfo(this.FullPath, out srpIVsHierarchy, out vsitemid, out ppIVsPersistDocData, out pVsDocCookie); if (srpIVsHierarchy == null || pVsDocCookie == VsConstants.VSDOCCOOKIE_NIL) return; pfOpen = true; // check if the doc is opened by another project if ((IVsHierarchy)this == srpIVsHierarchy || (IVsHierarchy)this.projectMgr == srpIVsHierarchy){ pfOpenByUs = true; } if (ppIVsPersistDocData != null){ int pf; ppIVsPersistDocData.IsDocDataDirty(out pf); pfDirty = (pf != 0); } }
internal static bool IsDirty(IVsPersistDocData docData) { int pfDirty; ErrorHandler.ThrowOnFailure(docData.IsDocDataDirty(out pfDirty)); return pfDirty > 0; }