• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DocumentId类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DocumentId的典型用法代码示例。如果您正苦于以下问题:C# DocumentId类的具体用法?C# DocumentId怎么用?C# DocumentId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DocumentId类属于命名空间,在下文中一共展示了DocumentId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddDocument

            public void AddDocument(DocumentId id)
            {
                var vsWorkspace = (VisualStudioWorkspaceImpl)_workspace;
                Contract.ThrowIfNull(vsWorkspace);

                var solution = vsWorkspace.CurrentSolution;
                if (!solution.ContainsDocument(id))
                {
                    // document is not part of the workspace (newly created document that is not applied to the workspace yet?)
                    return;
                }

                if (vsWorkspace.IsDocumentOpen(id))
                {
                    var document = vsWorkspace.GetHostDocument(id);
                    var undoHistory = _undoHistoryRegistry.RegisterHistory(document.GetOpenTextBuffer());

                    using (var undoTransaction = undoHistory.CreateTransaction(_description))
                    {
                        undoTransaction.AddUndo(new NoOpUndoPrimitive());
                        undoTransaction.Complete();
                    }

                    return;
                }

                // open and close the document so that it is included in the global undo transaction
                using (vsWorkspace.OpenInvisibleEditor(id))
                {
                    // empty
                }
            }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:32,代码来源:GlobalUndoServiceFactory.WorkspaceGlobalUndoTransaction.cs


示例2: GetFileCodeModel

        public override EnvDTE.FileCodeModel GetFileCodeModel(DocumentId documentId)
        {
            if (documentId == null)
            {
                throw new ArgumentNullException("documentId");
            }

            var project = ProjectTracker.GetProject(documentId.ProjectId);
            if (project == null)
            {
                throw new ArgumentException(ServicesVSResources.DocumentIdNotFromWorkspace, "documentId");
            }

            var document = project.GetDocumentOrAdditionalDocument(documentId);
            if (document == null)
            {
                throw new ArgumentException(ServicesVSResources.DocumentIdNotFromWorkspace, "documentId");
            }

            var provider = project as IProjectCodeModelProvider;
            if (provider != null)
            {
                var projectCodeModel = provider.ProjectCodeModel;
                if (projectCodeModel.CanCreateFileCodeModelThroughProject(document.FilePath))
                {
                    return (EnvDTE.FileCodeModel)projectCodeModel.CreateFileCodeModelThroughProject(document.FilePath);
                }
            }

            return null;
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:31,代码来源:RoslynVisualStudioWorkspace.cs


示例3: GetAdjustedDiagnosticSpan

        public void GetAdjustedDiagnosticSpan(
            DocumentId documentId, Location location,
            out TextSpan sourceSpan, out FileLinePositionSpan originalLineInfo, out FileLinePositionSpan mappedLineInfo)
        {
            sourceSpan = location.SourceSpan;
            originalLineInfo = location.GetLineSpan();
            mappedLineInfo = location.GetMappedLineSpan();

            // check quick bail out case.
            if (location == Location.None)
            {
                return;
            }
            // Update the original source span, if required.
            if (!TryAdjustSpanIfNeededForVenus(documentId, originalLineInfo, mappedLineInfo, out var originalSpan, out var mappedSpan))
            {
                return;
            }

            if (originalSpan.Start != originalLineInfo.StartLinePosition || originalSpan.End != originalLineInfo.EndLinePosition)
            {
                originalLineInfo = new FileLinePositionSpan(originalLineInfo.Path, originalSpan.Start, originalSpan.End);

                var textLines = location.SourceTree.GetText().Lines;
                var startPos = textLines.GetPosition(originalSpan.Start);
                var endPos = textLines.GetPosition(originalSpan.End);

                sourceSpan = TextSpan.FromBounds(startPos, Math.Max(startPos, endPos));
            }

            if (mappedSpan.Start != mappedLineInfo.StartLinePosition || mappedSpan.End != mappedLineInfo.EndLinePosition)
            {
                mappedLineInfo = new FileLinePositionSpan(mappedLineInfo.Path, mappedSpan.Start, mappedSpan.End);
            }
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:35,代码来源:VisualStudioVenusSpanMappingService.cs


示例4: RaiseWorkspaceChangedEventAsync

        protected Task RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind kind, Solution oldSolution, Solution newSolution, ProjectId projectId = null, DocumentId documentId = null)
        {
            if (newSolution == null)
            {
                throw new ArgumentNullException("newSolution");
            }

            if (oldSolution == newSolution)
            {
                return SpecializedTasks.EmptyTask;
            }

            if (projectId == null && documentId != null)
            {
                projectId = documentId.ProjectId;
            }

            var handlers = this.eventMap.GetEventHandlers<EventHandler<WorkspaceChangeEventArgs>>(WorkspaceChangeEventName);
            if (handlers.Length > 0)
            {
                return this.ScheduleTask(() =>
                {
                    var args = new WorkspaceChangeEventArgs(kind, oldSolution, newSolution, projectId, documentId);
                    foreach (var handler in handlers)
                    {
                        handler(this, args);
                    }
                }, "Workspace.WorkspaceChanged");
            }
            else
            {
                return SpecializedTasks.EmptyTask;
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:34,代码来源:Workspace_Events.cs


示例5: DiagnosticDataLocation

 public DiagnosticDataLocation(
     DocumentId documentId = null,
     TextSpan? sourceSpan = null,
     string originalFilePath = null,
     int originalStartLine = 0,
     int originalStartColumn = 0,
     int originalEndLine = 0,
     int originalEndColumn = 0,
     string mappedFilePath = null,
     int mappedStartLine = 0,
     int mappedStartColumn = 0,
     int mappedEndLine = 0,
     int mappedEndColumn = 0)
 {
     DocumentId = documentId;
     SourceSpan = sourceSpan;
     MappedFilePath = mappedFilePath;
     MappedStartLine = mappedStartLine;
     MappedStartColumn = mappedStartColumn;
     MappedEndLine = mappedEndLine;
     MappedEndColumn = mappedEndColumn;
     OriginalFilePath = originalFilePath;
     OriginalStartLine = originalStartLine;
     OriginalStartColumn = originalStartColumn;
     OriginalEndLine = originalEndLine;
     OriginalEndColumn = originalEndColumn;
 }
开发者ID:robertoenbarcelona,项目名称:roslyn,代码行数:27,代码来源:DiagnosticData.cs


示例6: DocumentInfo

        /// <summary>
        /// Create a new instance of a <see cref="DocumentInfo"/>.
        /// </summary>
        private DocumentInfo(
            DocumentId id,
            string name,
            IEnumerable<string> folders,
            SourceCodeKind sourceCodeKind,
            TextLoader loader,
            string filePath,
            bool isGenerated)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            this.Id = id;
            this.Name = name;
            this.Folders = folders.ToImmutableReadOnlyListOrEmpty();
            this.SourceCodeKind = sourceCodeKind;
            this.TextLoader = loader;
            this.FilePath = filePath;
            this.IsGenerated = isGenerated;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:30,代码来源:DocumentInfo.cs


示例7: RaiseWorkspaceChangedEventAsync

        protected Task RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind kind, Solution oldSolution, Solution newSolution, ProjectId projectId = null, DocumentId documentId = null)
        {
            if (newSolution == null)
            {
                throw new ArgumentNullException(nameof(newSolution));
            }

            if (oldSolution == newSolution)
            {
                return SpecializedTasks.EmptyTask;
            }

            if (projectId == null && documentId != null)
            {
                projectId = documentId.ProjectId;
            }

            var ev = _eventMap.GetEventHandlers<EventHandler<WorkspaceChangeEventArgs>>(WorkspaceChangeEventName);
            if (ev.HasHandlers)
            {
                return this.ScheduleTask(() =>
                {
                    var args = new WorkspaceChangeEventArgs(kind, oldSolution, newSolution, projectId, documentId);
                    ev.RaiseEvent(handler => handler(this, args));
                }, "Workspace.WorkspaceChanged");
            }
            else
            {
                return SpecializedTasks.EmptyTask;
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:31,代码来源:Workspace_Events.cs


示例8: DiagnosticsUpdatedArgs

 public DiagnosticsUpdatedArgs(
     object id, Workspace workspace, Solution solution, ProjectId projectId, DocumentId documentId, ImmutableArray<DiagnosticData> diagnostics) :
         base(id, workspace, projectId, documentId)
 {
     this.Solution = solution;
     this.Diagnostics = diagnostics;
 }
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:7,代码来源:DiagnosticsUpdatedArgs.cs


示例9: SolutionPreviewItem

 public SolutionPreviewItem(ProjectId projectId, DocumentId documentId, string text)
 {
     ProjectId = projectId;
     DocumentId = documentId;
     Text = text;
     LazyPreview = c => Task.FromResult<object>(text);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:7,代码来源:SolutionPreviewItem.cs


示例10: TodoItem

        public TodoItem(
            int priority,
            string message,
            Workspace workspace,
            DocumentId documentId,
            int mappedLine,
            int originalLine,
            int mappedColumn,
            int originalColumn,
            string mappedFilePath,
            string originalFilePath)
        {
            Priority = priority;
            Message = message;

            Workspace = workspace;
            DocumentId = documentId;

            MappedLine = mappedLine;
            MappedColumn = mappedColumn;
            MappedFilePath = mappedFilePath;

            OriginalLine = originalLine;
            OriginalColumn = originalColumn;
            OriginalFilePath = originalFilePath;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:26,代码来源:TodoItem.cs


示例11: ConflictLocationInfo

 public ConflictLocationInfo(RelatedLocation location)
 {
     Debug.Assert(location.ComplexifiedTargetSpan.Contains(location.ConflictCheckSpan) || location.Type == RelatedLocationType.UnresolvableConflict);
     this.ComplexifiedSpan = location.ComplexifiedTargetSpan;
     this.DocumentId = location.DocumentId;
     this.OriginalIdentifierSpan = location.ConflictCheckSpan;
 }
开发者ID:nagyist,项目名称:roslyn,代码行数:7,代码来源:ConflictResolver.Session.cs


示例12: Session

            public Session(
                RenameLocations renameLocationSet,
                Location renameSymbolDeclarationLocation,
                string originalText,
                string replacementText,
                OptionSet optionSet,
                Func<IEnumerable<ISymbol>, bool?> newSymbolsAreValid,
                CancellationToken cancellationToken)
            {
                _renameLocationSet = renameLocationSet;
                _renameSymbolDeclarationLocation = renameSymbolDeclarationLocation;
                _originalText = originalText;
                _replacementText = replacementText;
                _optionSet = optionSet;
                _hasConflictCallback = newSymbolsAreValid;
                _cancellationToken = cancellationToken;

                _renamedSymbolDeclarationAnnotation = new RenameAnnotation();

                _conflictLocations = SpecializedCollections.EmptySet<ConflictLocationInfo>();
                _replacementTextValid = true;
                _possibleNameConflicts = new List<string>();

                // only process documents which possibly contain the identifiers.
                _documentsIdsToBeCheckedForConflict = new HashSet<DocumentId>();
                _documentIdOfRenameSymbolDeclaration = renameLocationSet.Solution.GetDocument(renameSymbolDeclarationLocation.SourceTree).Id;

                _renameAnnotations = new AnnotationTable<RenameAnnotation>(RenameAnnotation.Kind);
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:29,代码来源:ConflictResolver.Session.cs


示例13: TryAdjustSpanIfNeededForVenus

        private bool TryAdjustSpanIfNeededForVenus(
            DocumentId documentId, FileLinePositionSpan originalLineInfo, FileLinePositionSpan mappedLineInfo, out LinePositionSpan originalSpan, out LinePositionSpan mappedSpan)
        {
            var startChanged = true;
            MappedSpan startLineColumn;
            if (!TryAdjustSpanIfNeededForVenus(_workspace, documentId, originalLineInfo.StartLinePosition.Line, originalLineInfo.StartLinePosition.Character, out startLineColumn))
            {
                startChanged = false;
                startLineColumn = new MappedSpan(originalLineInfo.StartLinePosition.Line, originalLineInfo.StartLinePosition.Character, mappedLineInfo.StartLinePosition.Line, mappedLineInfo.StartLinePosition.Character);
            }

            var endChanged = true;
            MappedSpan endLineColumn;
            if (!TryAdjustSpanIfNeededForVenus(_workspace, documentId, originalLineInfo.EndLinePosition.Line, originalLineInfo.EndLinePosition.Character, out endLineColumn))
            {
                endChanged = false;
                endLineColumn = new MappedSpan(originalLineInfo.EndLinePosition.Line, originalLineInfo.EndLinePosition.Character, mappedLineInfo.EndLinePosition.Line, mappedLineInfo.EndLinePosition.Character);
            }

            // start and end position can be swapped when mapped between primary and secondary buffer if start position is within visible span (at the edge)
            // but end position is outside of visible span. in that case, swap start and end position.
            originalSpan = GetLinePositionSpan(startLineColumn.OriginalLinePosition, endLineColumn.OriginalLinePosition);
            mappedSpan = GetLinePositionSpan(startLineColumn.MappedLinePosition, endLineColumn.MappedLinePosition);

            return startChanged || endChanged;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:26,代码来源:VisualStudioVenusSpanMappingService.cs


示例14: SearchRefactoringWorkitem

 internal SearchRefactoringWorkitem(ICodeHistoryRecord latestRecord, 
     DocumentId documentId)
 {
     this.latestRecord = latestRecord;
     this.documentId = documentId;
     logger = NLoggerUtil.GetNLogger(typeof(SearchRefactoringWorkitem));
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:7,代码来源:SearchRefactoringComponent.cs


示例15: CreateRecoverableText

 protected static ValueSource<TextAndVersion> CreateRecoverableText(TextLoader loader, DocumentId documentId, SolutionServices services)
 {
     return new RecoverableTextAndVersion(
         new AsyncLazy<TextAndVersion>(c => LoadTextAsync(loader, documentId, services, c), cacheResult: false),
         services.TemporaryStorage,
         services.TextCache);
 }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:7,代码来源:TextDocumentState.cs


示例16: DiagnosticGetter

            public DiagnosticGetter(
                DiagnosticIncrementalAnalyzer owner,
                Solution solution,
                ProjectId projectId,
                DocumentId documentId,
                object id,
                bool includeSuppressedDiagnostics)
            {
                Owner = owner;
                CurrentSolution = solution;

                CurrentDocumentId = documentId;
                CurrentProjectId = projectId ?? documentId?.ProjectId;

                Id = id;
                IncludeSuppressedDiagnostics = includeSuppressedDiagnostics;

                // try to retrieve projectId/documentId from id if possible.
                var argsId = id as LiveDiagnosticUpdateArgsId;
                if (argsId != null)
                {
                    CurrentDocumentId = CurrentDocumentId ?? argsId.Key as DocumentId;
                    CurrentProjectId = CurrentProjectId ?? (argsId.Key as ProjectId) ?? CurrentDocumentId.ProjectId;
                }

                _builder = null;
            }
开发者ID:TyOverby,项目名称:roslyn,代码行数:27,代码来源:DiagnosticIncrementalAnalyzer_GetDiagnostics.cs


示例17: GetAdjustedDiagnosticSpan

        public void GetAdjustedDiagnosticSpan(
            DocumentId documentId, Location location,
            out TextSpan sourceSpan, out FileLinePositionSpan originalLineInfo, out FileLinePositionSpan mappedLineInfo)
        {
            sourceSpan = location.SourceSpan;
            originalLineInfo = location.GetLineSpan();
            mappedLineInfo = location.GetMappedLineSpan();

            // Update the original source span, if required.
            LinePositionSpan originalSpan;
            LinePositionSpan mappedSpan;
            if (!TryAdjustSpanIfNeededForVenus(documentId, originalLineInfo, mappedLineInfo, out originalSpan, out mappedSpan))
            {
                return;
            }

            if (originalSpan.Start != originalLineInfo.StartLinePosition || originalSpan.End != originalLineInfo.EndLinePosition)
            {
                originalLineInfo = new FileLinePositionSpan(originalLineInfo.Path, originalSpan.Start, originalSpan.End);

                var textLines = location.SourceTree.GetText().Lines;
                var startPos = textLines.GetPosition(originalSpan.Start);
                var endPos = textLines.GetPosition(originalSpan.End);
                sourceSpan = new TextSpan(startPos, endPos - startPos);
            }

            if (mappedSpan.Start != mappedLineInfo.StartLinePosition || mappedSpan.End != mappedLineInfo.EndLinePosition)
            {
                mappedLineInfo = new FileLinePositionSpan(mappedLineInfo.Path, mappedSpan.Start, mappedSpan.End);
            }
        }
开发者ID:JinGuoGe,项目名称:roslyn,代码行数:31,代码来源:VisualStudioVenusSpanMappingService.cs


示例18: UpdateDocument

 internal static Solution UpdateDocument(this Solution solution, DocumentId id, IEnumerable<TextChange> textChanges, CancellationToken cancellationToken)
 {
     var oldDocument = solution.GetDocument(id);
     var oldText = oldDocument.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken);
     var newText = oldText.WithChanges(textChanges);
     return solution.WithDocumentText(id, newText, PreservationMode.PreserveIdentity);
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:7,代码来源:WorkspaceExtensions.cs


示例19: LoadTextAndVersionAsync

        /// <summary>
        /// Load a text and a version of the document in the workspace.
        /// </summary>
        /// <exception cref="IOException"></exception>
        public override async Task<TextAndVersion> LoadTextAndVersionAsync(Workspace workspace, DocumentId documentId, CancellationToken cancellationToken)
        {
            DateTime prevLastWriteTime = FileUtilities.GetFileTimeStamp(_path);

            TextAndVersion textAndVersion;

            // Open file for reading with FileShare mode read/write/delete so that we do not lock this file.
            using (var stream = FileUtilities.RethrowExceptionsAsIOException(() => new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete, bufferSize: 4096, useAsync: true)))
            {
                var version = VersionStamp.Create(prevLastWriteTime);

                // we do this so that we asynchronously read from file. and this should allocate less for IDE case. 
                // but probably not for command line case where it doesn't use more sophisticated services.
                using (var readStream = await SerializableBytes.CreateReadableStreamAsync(stream, cancellationToken: cancellationToken).ConfigureAwait(false))
                {
                    var text = CreateText(readStream, workspace);
                    textAndVersion = TextAndVersion.Create(text, version, _path);
                }
            }

            // Check if the file was definitely modified and closed while we were reading. In this case, we know the read we got was
            // probably invalid, so throw an IOException which indicates to our caller that we should automatically attempt a re-read.
            // If the file hasn't been closed yet and there's another writer, we will rely on file change notifications to notify us
            // and reload the file.
            DateTime newLastWriteTime = FileUtilities.GetFileTimeStamp(_path);
            if (!newLastWriteTime.Equals(prevLastWriteTime))
            {
                var message = string.Format(WorkspacesResources.File_was_externally_modified_colon_0, _path);
                throw new IOException(message);
            }

            return textAndVersion;
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:37,代码来源:FileTextLoader.cs


示例20: OpenAdditionalDocument

        public override void OpenAdditionalDocument(DocumentId documentId, bool activate = true)
        {
            var document = this.CurrentSolution.GetAdditionalDocument(documentId);
            var text = document.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None);

            this.OnAdditionalDocumentOpened(documentId, text.Container);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:PreviewWorkspace.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DocumentObject类代码示例发布时间:2022-05-24
下一篇:
C# DocumentFormat类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap