当前位置: 首页>>代码示例>>C#>>正文


C# IVisualStudioHostDocument类代码示例

本文整理汇总了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;
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:16,代码来源:LinkedFileUtilities.cs

示例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);
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:23,代码来源:LinkedFileUtilities.cs

示例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);
        }
开发者ID:rgani,项目名称:roslyn,代码行数:23,代码来源:RoslynVisualStudioWorkspace.cs

示例4: IsCurrentContextHierarchy

 public static bool IsCurrentContextHierarchy(IVisualStudioHostDocument document, IVsRunningDocumentTable4 runningDocumentTable)
 {
     return document.Project.Hierarchy == GetContextHierarchy(document, runningDocumentTable);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:4,代码来源:LinkedFileUtilities.cs

示例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);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:27,代码来源:DocumentProvider.cs

示例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();
            }
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:27,代码来源:AbstractProject.cs

示例7: RemoveAdditionalDocument

        internal void RemoveAdditionalDocument(IVisualStudioHostDocument document)
        {
            AssertIsForeground();

            lock (_gate)
            {
                _additionalDocuments.Remove(document.Id);
                _documentMonikers.Remove(document.Key.Moniker);
            }

            UninitializeAdditionalDocument(document);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:12,代码来源:AbstractProject.cs

示例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);
            }
        }
开发者ID:xyh413,项目名称:roslyn,代码行数:12,代码来源:AbstractProject.cs

示例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;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:9,代码来源:XamlTextViewCreationListener.cs

示例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();
        }
开发者ID:xyh413,项目名称:roslyn,代码行数:18,代码来源:AbstractProject.cs

示例11: RemoveAdditionalDocument

        internal void RemoveAdditionalDocument(IVisualStudioHostDocument document)
        {
            _additionalDocuments.Remove(document.Id);
            _documentMonikers.Remove(document.Key.Moniker);

            UninitializeAdditionalDocument(document);
        }
开发者ID:xyh413,项目名称:roslyn,代码行数:7,代码来源:AbstractProject.cs

示例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);
 }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:11,代码来源:LinkedFileUtilities.cs

示例13: GetContextHierarchyInternal

        private IVsHierarchy GetContextHierarchyInternal(IVisualStudioHostDocument document, IVsRunningDocumentTable4 runningDocumentTable)
        {
            AssertIsForeground();

            return GetSharedItemContextHierarchy(document) ?? GetContextHierarchyFromRunningDocumentTable(document, runningDocumentTable) ?? document.Project.Hierarchy;
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:6,代码来源:LinkedFileUtilities.cs

示例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);
 }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:5,代码来源:LinkedFileUtilities.cs

示例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);
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:24,代码来源:DocumentProvider.cs


注:本文中的IVisualStudioHostDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。