RunningDocumentTable Class

Definition

Provides access to the running document table (RDT) that tracks all currently opened documents in Visual Studio.

public ref class RunningDocumentTable : System::Collections::Generic::IEnumerable<Microsoft::VisualStudio::Shell::RunningDocumentInfo>
public class RunningDocumentTable : System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.Shell.RunningDocumentInfo>
type RunningDocumentTable = class
    interface seq<RunningDocumentInfo>
    interface IEnumerable
Public Class RunningDocumentTable
Implements IEnumerable(Of RunningDocumentInfo)
Inheritance
RunningDocumentTable
Implements

Examples

This example shows how to use this class from a language service to obtain the owning project of a file currently open in the editor.

using Microsoft.VisualStudio.Package;  

namespace MyLanguagePackage  
{  
    public class MyLanguageService : LanguageService  
    {  
        IServiceProvider serviceProvider;  

        public IVsHierarchy GetOwningProject(Source src)  
        {  
            RunningDocumentTable rdt = new RunningDocumentTable(this.serviceProvider);  
            string filename = src.GetFilePath();  
            return rdt.GetHierarchyItem(filename);  
        }  
    }  
}  

Remarks

The running document table is used to track all documents that are currently opened in Visual Studio, whether they are visible or not. A VSPackage (see VSPackages) can access the RDT by calling the IServiceProvider.QueryService method on a service provider with the service ID of the SVsRunningDocumentTable service and the GUID of the IVsRunningDocumentTable interface.

This class simplifies access to the RDT for VSPackages by hiding the details of the IVsRunningDocumentTable interface behind a collection of useful methods. Note that the <xref:Microsoft.VisualStudio.Package.RunningDocumentTable> class is used only for accessing document information. If you want to track RDT events, you must obtain the IVsRunningDocumentTable interface yourself (through the IServiceProvider.QueryService method on a service provider) and call the AdviseRunningDocTableEvents method with your own implementation of the IVsRunningDocTableEvents interface (or its derivatives).

The Source class uses this class to obtain the owning project of a document when building the list of error task items for the task windows.

Notes to Callers

Instantiate this class to obtain information about an open document. The resulting object is typically cached to enhance performance. Note that this class does not provide complete access to the RDT.

Constructors

RunningDocumentTable()

Instantiates a new instance of the RunningDocumentTable.

RunningDocumentTable(IServiceProvider)

Initializes a new instance of the Microsoft.VisualStudio.Package.RunningDocumentTable class.

Methods

Advise(IVsRunningDocTableEvents)

Enables the client to receive events about changes to the Running Document Table (RDT).

CloseDocument(__FRAMECLOSE, UInt32)

Closes the document.

CloseHierarchy(__FRAMECLOSE, IVsHierarchy)

Closes the project hierarchy.

CloseSolution(__FRAMECLOSE)

Closes the solution.

FindAndLockDocumentEx(_VSRDTFLAGS, String, IVsHierarchy, UInt32)

Finds and locks the document.

FindAndLockDocumentEx(_VSRDTFLAGS, String, IVsHierarchy, UInt32, IVsHierarchy, UInt32, UInt32)

Finds and locks the document.

FindAndLockDocumentEx(_VSRDTFLAGS, String, IVsHierarchy, UInt32, UInt32)

Finds and locks the document.

FindDocument(String)

Gets an object from the Running Document Table (RDT) that represents the document specified by the given path.

FindDocument(String, IVsHierarchy, UInt32, UInt32)

Gets an object, cookie, and owning project type from the Running Document Table (RDT) for the document specified by the given path.

FindDocument(String, UInt32)

Gets a cookie from the Running Document Table (RDT) that represents the document specified by the given path.

FindOrRegisterAndLockDocument(_VSRDTFLAGS, String, IVsHierarchy, UInt32, Object)
FindOrRegisterAndLockDocument(_VSRDTFLAGS, String, IVsHierarchy, UInt32, Object, IVsHierarchy, UInt32, UInt32)
FindOrRegisterAndLockDocument(_VSRDTFLAGS, String, IVsHierarchy, UInt32, Object, UInt32)
GetDocumentInfo(String)

Gets information about a document registered in the Running Document Table, given the identifier of the document.

GetDocumentInfo(UInt32)

Gets information about a document registered in the Running Document Table, given the identifier of the document.

GetEnumerator()

Gets an enumerator of the documents in the Running Document Table.

GetHierarchyItem(String)

Gets the project that owns the specified document.

GetRelatedSaveTreeItems(UInt32, UInt32)

Gets an array of save tree items.

GetRunningDocumentContents(String)

Uses the Running Document Table (RDT) to obtain the contents of a document given the path to the document.

GetRunningDocumentContents(UInt32)

Uses the Running Document Table (RDT) to obtain the contents of a document given the path to the document.

LockDocument(_VSRDTFLAGS, UInt32)

Gets a read or edit lock on the specified document.

QueryCloseRunningDocument(String)

Determines whether the document can be closed.

RegisterAndLockDocument(_VSRDTFLAGS, String, IVsHierarchy, UInt32, IntPtr)

Creates an entry in the running document table when a document is created or opened.

RenameDocument(String, String, IVsHierarchy, UInt32)

Renames a document and optionally gives ownership of the document to the specified project.

SaveFileIfDirty(String)

Saves the specified file if it has changed since the last save.

Unadvise(UInt32)

Indicates the client is no longer interested in receiving Running Document Table (RDT) events.

UnlockDocument(_VSRDTFLAGS, UInt32)

Releases a read or edit lock on the open document.

Explicit Interface Implementations

IEnumerable.GetEnumerator()

Enumerates the documents in the Running Document Table.

Extension Methods

EmptyIfNull<T>(IEnumerable<T>)

Applies to