RunningDocumentTable Class
Provides access to the Running Document Table (RDT) that tracks all currently opened documents in Visual Studio.
Namespace: Microsoft.VisualStudio.Shell
Assemblies: Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)
Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)
Microsoft.VisualStudio.Shell.9.0 (in Microsoft.VisualStudio.Shell.9.0.dll)
Syntax
'宣言
Public Class RunningDocumentTable _
Implements IEnumerable(Of RunningDocumentInfo), IEnumerable
'使用
Dim instance As RunningDocumentTable
public class RunningDocumentTable : IEnumerable<RunningDocumentInfo>,
IEnumerable
public ref class RunningDocumentTable : IEnumerable<RunningDocumentInfo>,
IEnumerable
type RunningDocumentTable =
class
interface IEnumerable<RunningDocumentInfo>
interface IEnumerable
end
public class RunningDocumentTable implements IEnumerable<RunningDocumentInfo>, IEnumerable
Remarks
The RDT 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 QueryService(Guid%, Guid%, IntPtr%) method on a service provider with the service ID SVsRunningDocumentTable and the GUID of the IVsRunningDocumentTable interface.
The managed package framework's (MPF) RunningDocumentTable 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 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 QueryService(Guid%, Guid%, IntPtr%) method on a service provider) and call the AdviseRunningDocTableEvents method with your own implementation of the IVsRunningDocTableEvents interface (or its derivatives).
The RunningDocumentTable class is primarily used by the MPF classes. For example, the Source class uses the RunningDocumentTable class to obtain the owning project of a document when building the list of error task items for the task windows.
Notes to Implementers
This class is used to simplify access to finding information about open documents and has no methods that can be overridden. There is nothing to implement.
Notes to Callers
Instantiate the RunningDocumentTable class to obtain information about an open document. The resulting RunningDocumentTable object is typically cached to enhance performance. Note that this class does not provide complete access to the RDT.
Examples
This example shows how to use the RunningDocumentTable object 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);
}
}
}
Inheritance Hierarchy
System.Object
Microsoft.VisualStudio.Shell.RunningDocumentTable
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.