本文整理汇总了C#中IVisualStudioHostDocument类的典型用法代码示例。如果您正苦于以下问题:C# IVisualStudioHostDocument类的具体用法?C# IVisualStudioHostDocument怎么用?C# IVisualStudioHostDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IVisualStudioHostDocument类属于命名空间,在下文中一共展示了IVisualStudioHostDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetContextHierarchyFromRunningDocumentTable
/// <summary>
/// If the document is open in the running document table, this returns the hierarchy in
/// which it is currently open. Otherwise, it returns null.
/// </summary>
private IVsHierarchy GetContextHierarchyFromRunningDocumentTable(IVisualStudioHostDocument document, IVsRunningDocumentTable4 runningDocumentTable)
{
AssertIsForeground();
if (!runningDocumentTable.TryGetCookieForInitializedDocument(document.Key.Moniker, out var docCookie))
{
return null;
}
runningDocumentTable.GetDocumentHierarchyItem(docCookie, out var hierarchy, out var itemid);
return hierarchy;
}
示例2: GetSharedItemContextHierarchy
/// <summary>
/// If the document is in a Shared Code project, this returns that project's
/// SharedItemContextHierarchy. Otherwise, it returns null.
/// </summary>
private IVsHierarchy GetSharedItemContextHierarchy(IVisualStudioHostDocument document)
{
AssertIsForeground();
var itemId = document.GetItemId();
if (itemId == (uint)VSConstants.VSITEMID.Nil)
{
// the document is no longer part of the solution
return null;
}
var sharedHierarchy = GetSharedHierarchyForItem(document.Project.Hierarchy, itemId);
if (sharedHierarchy == null)
{
return null;
}
return GetSharedItemContextHierarchy(sharedHierarchy);
}
示例3: OpenInvisibleEditor
internal override IInvisibleEditor OpenInvisibleEditor(IVisualStudioHostDocument hostDocument)
{
// We need to ensure the file is saved, only if a global undo transaction is open
var globalUndoService = this.Services.GetService<IGlobalUndoService>();
var needsSave = globalUndoService.IsGlobalTransactionOpen(this);
var needsUndoDisabled = false;
if (needsSave)
{
if (this.CurrentSolution.ContainsDocument(hostDocument.Id))
{
// Disable undo on generated documents
needsUndoDisabled = this.Services.GetService<IGeneratedCodeRecognitionService>().IsGeneratedCode(this.CurrentSolution.GetDocument(hostDocument.Id));
}
else
{
// Enable undo on "additional documents" or if no document can be found.
needsUndoDisabled = false;
}
}
return new InvisibleEditor(ServiceProvider, hostDocument.FilePath, needsSave, needsUndoDisabled);
}
示例4: IsCurrentContextHierarchy
public static bool IsCurrentContextHierarchy(IVisualStudioHostDocument document, IVsRunningDocumentTable4 runningDocumentTable)
{
return document.Project.Hierarchy == GetContextHierarchy(document, runningDocumentTable);
}
示例5: NotifyDocumentRegisteredToProjectAndStartToRaiseEvents_Core
private void NotifyDocumentRegisteredToProjectAndStartToRaiseEvents_Core(IVisualStudioHostDocument document, CancellationToken cancellationToken)
{
AssertIsForeground();
cancellationToken.ThrowIfCancellationRequested();
// Ignore any other unknown kinds of documents
var standardDocument = document as StandardTextDocument;
if (standardDocument == null)
{
return;
}
// If it's already open, then we have nothing more to do here.
if (standardDocument.IsOpen)
{
return;
}
if (_runningDocumentTable.TryGetCookieForInitializedDocument(document.Key.Moniker, out var docCookie))
{
TryProcessOpenForDocCookie(docCookie, cancellationToken);
}
cancellationToken.ThrowIfCancellationRequested();
CancelPendingDocumentInitializationTask(document);
}
示例6: AddAdditionalDocument
internal void AddAdditionalDocument(IVisualStudioHostDocument document, bool isCurrentContext)
{
AssertIsForeground();
lock (_gate)
{
_additionalDocuments.Add(document.Id, document);
_documentMonikers.Add(document.Key.Moniker, document);
}
if (_pushingChangesToWorkspaceHosts)
{
this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnAdditionalDocumentAdded(document.GetInitialState()));
if (document.IsOpen)
{
this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnAdditionalDocumentOpened(document.Id, document.GetOpenTextBuffer(), isCurrentContext));
}
}
DocumentProvider.NotifyDocumentRegisteredToProjectAndStartToRaiseEvents(document);
if (!_pushingChangesToWorkspaceHosts && document.IsOpen)
{
StartPushingToWorkspaceAndNotifyOfOpenDocuments();
}
}
示例7: RemoveAdditionalDocument
internal void RemoveAdditionalDocument(IVisualStudioHostDocument document)
{
AssertIsForeground();
lock (_gate)
{
_additionalDocuments.Remove(document.Id);
_documentMonikers.Remove(document.Key.Moniker);
}
UninitializeAdditionalDocument(document);
}
示例8: RemoveGeneratedDocument
private void RemoveGeneratedDocument(IVisualStudioHostDocument document)
{
// We do not want to allow message pumping/reentrancy when processing project system changes.
using (Dispatcher.CurrentDispatcher.DisableProcessing())
{
_documents.Remove(document.Id);
_documentMonikers.Remove(document.Key.Moniker);
UninitializeDocument(document);
OnDocumentRemoved(document.Key.Moniker);
}
}
示例9: TryCreateXamlDocument
private bool TryCreateXamlDocument(AbstractProject project, string filePath, out IVisualStudioHostDocument vsDocument)
{
vsDocument = _vsWorkspace.ProjectTracker.DocumentProvider.TryGetDocumentForFile(
project, filePath, SourceCodeKind.Regular,
tb => tb.ContentType.IsOfType(ContentTypeNames.XamlContentType),
_ => SpecializedCollections.EmptyReadOnlyList<string>());
return vsDocument != null;
}
示例10: UninitializeAdditionalDocument
private void UninitializeAdditionalDocument(IVisualStudioHostDocument document)
{
if (_pushingChangesToWorkspaceHosts)
{
if (document.IsOpen)
{
this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnAdditionalDocumentClosed(document.Id, document.GetOpenTextBuffer(), document.Loader));
}
this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnAdditionalDocumentRemoved(document.Id));
}
document.Opened -= s_additionalDocumentOpenedEventHandler;
document.Closing -= s_additionalDocumentClosingEventHandler;
document.UpdatedOnDisk -= s_additionalDocumentUpdatedOnDiskEventHandler;
document.Dispose();
}
示例11: RemoveAdditionalDocument
internal void RemoveAdditionalDocument(IVisualStudioHostDocument document)
{
_additionalDocuments.Remove(document.Id);
_documentMonikers.Remove(document.Key.Moniker);
UninitializeAdditionalDocument(document);
}
示例12: GetContextHierarchy
/// <summary>
/// Finds the current context hierarchy for the given document. If the document is in a
/// Shared Code project, this returns that project's SharedItemContextHierarchy. If the
/// document is linked into multiple projects, this returns the hierarchy in which it is
/// currently open as indicated by the running document table. Otherwise, it returns the
/// hierarchy of the document's project.
/// </summary>
public static IVsHierarchy GetContextHierarchy(IVisualStudioHostDocument document, IVsRunningDocumentTable4 runningDocumentTable)
{
return s_singleton.GetContextHierarchyInternal(document, runningDocumentTable);
}
示例13: GetContextHierarchyInternal
private IVsHierarchy GetContextHierarchyInternal(IVisualStudioHostDocument document, IVsRunningDocumentTable4 runningDocumentTable)
{
AssertIsForeground();
return GetSharedItemContextHierarchy(document) ?? GetContextHierarchyFromRunningDocumentTable(document, runningDocumentTable) ?? document.Project.Hierarchy;
}
示例14: IsCurrentContextHierarchy
public static bool IsCurrentContextHierarchy(IVisualStudioHostDocument document, IVsRunningDocumentTable4 runningDocumentTable)
{
// runningDocumentTable might be null for tests.
return runningDocumentTable != null && document.Project.Hierarchy == GetContextHierarchy(document, runningDocumentTable);
}
示例15: NotifyDocumentRegisteredToProject
/// <summary>
/// Notifies the document provider that this document is now registered in a project.
/// </summary>
public void NotifyDocumentRegisteredToProject(IVisualStudioHostDocument document)
{
// Ignore any other unknown kinds of documents
var standardDocument = document as StandardTextDocument;
if (standardDocument == null)
{
return;
}
// If it's already open, then we have nothing more to do here.
if (standardDocument.IsOpen)
{
return;
}
uint docCookie;
if (RunningDocumentTable.TryGetCookieForInitializedDocument(document.Key.Moniker, out docCookie))
{
TryProcessOpenForDocCookie(docCookie);
}
}