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


C# CodeAnalysis.TextLoader类代码示例

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


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

示例1: 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

示例2: 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

示例3: StandardTextDocument

            public StandardTextDocument(
                DocumentProvider documentProvider,
                IVisualStudioHostProject project,
                DocumentKey documentKey,
                IReadOnlyList<string> folderNames,
                SourceCodeKind sourceCodeKind,
                ITextUndoHistoryRegistry textUndoHistoryRegistry,
                IVsFileChangeEx fileChangeService,
                ITextBuffer openTextBuffer,
                DocumentId id,
                EventHandler updatedOnDiskHandler,
                EventHandler<bool> openedHandler,
                EventHandler<bool> closingHandler)
            {
                Contract.ThrowIfNull(documentProvider);

                this.Project = project;
                this.Id = id ?? DocumentId.CreateNewId(project.Id, documentKey.Moniker);
                this.Folders = folderNames;

                _documentProvider = documentProvider;

                this.Key = documentKey;
                this.SourceCodeKind = sourceCodeKind;
                _itemMoniker = documentKey.Moniker;
                _textUndoHistoryRegistry = textUndoHistoryRegistry;
                _fileChangeTracker = new FileChangeTracker(fileChangeService, this.FilePath);
                _fileChangeTracker.UpdatedOnDisk += OnUpdatedOnDisk;

                _openTextBuffer = openTextBuffer;
                _snapshotTracker = new ReiteratedVersionSnapshotTracker(openTextBuffer);

                // The project system does not tell us the CodePage specified in the proj file, so
                // we use null to auto-detect.
                _doNotAccessDirectlyLoader = new FileTextLoader(documentKey.Moniker, defaultEncoding: null);

                // If we aren't already open in the editor, then we should create a file change notification
                if (openTextBuffer == null)
                {
                    _fileChangeTracker.StartFileChangeListeningAsync();
                }

                if (updatedOnDiskHandler != null)
                {
                    UpdatedOnDisk += updatedOnDiskHandler;
                }

                if (openedHandler != null)
                {
                    Opened += openedHandler;
                }

                if (closingHandler != null)
                {
                    Closing += closingHandler;
                }
            }
开发者ID:natidea,项目名称:roslyn,代码行数:57,代码来源:DocumentProvider.StandardTextDocument.cs

示例4: Create

 public static DocumentInfo Create(
     DocumentId id,
     string name,
     IEnumerable<string> folders = null,
     SourceCodeKind sourceCodeKind = SourceCodeKind.Regular,
     TextLoader loader = null,
     string filePath = null,
     bool isGenerated = false)
 {
     return new DocumentInfo(id, name, folders, sourceCodeKind, loader, filePath, isGenerated);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:11,代码来源:DocumentInfo.cs

示例5: StandardTextDocument

            public StandardTextDocument(
                DocumentProvider documentProvider,
                IVisualStudioHostProject project,
                DocumentKey documentKey,
                uint itemId,
                SourceCodeKind sourceCodeKind,
                ITextBufferFactoryService textBufferFactoryService,
                ITextUndoHistoryRegistry textUndoHistoryRegistry,
                IVsFileChangeEx fileChangeService,
                ITextBuffer openTextBuffer,
                DocumentId id)
            {
                Contract.ThrowIfNull(documentProvider);
                Contract.ThrowIfNull(textBufferFactoryService);

                this.Project = project;
                this.Id = id ?? DocumentId.CreateNewId(project.Id, documentKey.Moniker);
                this.Folders = project.GetFolderNames(itemId);

                // TODO: 
                // this one doesn't work for asynchronous project load situation where shared projects is loaded after one uses shared file. 
                // we need to figure out what to do on those case. but this works for project k case.
                // opened an issue to track this issue - https://github.com/dotnet/roslyn/issues/1859
                this.SharedHierarchy = project.Hierarchy == null ? null : LinkedFileUtilities.GetSharedHierarchyForItem(project.Hierarchy, itemId);
                _documentProvider = documentProvider;

                this.Key = documentKey;
                this.SourceCodeKind = sourceCodeKind;
                _itemMoniker = documentKey.Moniker;
                _textBufferFactoryService = textBufferFactoryService;
                _textUndoHistoryRegistry = textUndoHistoryRegistry;
                _fileChangeTracker = new FileChangeTracker(fileChangeService, this.FilePath);
                _fileChangeTracker.UpdatedOnDisk += OnUpdatedOnDisk;

                _openTextBuffer = openTextBuffer;
                _snapshotTracker = new ReiteratedVersionSnapshotTracker(openTextBuffer);

                // The project system does not tell us the CodePage specified in the proj file, so
                // we use null to auto-detect.
                _doNotAccessDirectlyLoader = new FileTextLoader(documentKey.Moniker, defaultEncoding: null);

                // If we aren't already open in the editor, then we should create a file change notification
                if (openTextBuffer == null)
                {
                    _fileChangeTracker.StartFileChangeListeningAsync();
                }
            }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:47,代码来源:DocumentProvider.StandardTextDocument.cs

示例6: CreateStrongText

 private static ValueSource<TextAndVersion> CreateStrongText(TextLoader loader, DocumentId documentId, SolutionServices services)
 {
     return new AsyncLazy<TextAndVersion>(c => LoadTextAsync(loader, documentId, services, c), cacheResult: true);
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:4,代码来源:DocumentState.cs

示例7: WithDocumentTextLoader

 /// <summary>
 /// Creates a new solution instance with the document specified updated to have the text
 /// supplied by the text loader.
 /// </summary>
 public Solution WithDocumentTextLoader(DocumentId documentId, TextLoader loader, PreservationMode mode)
 {
     return WithDocumentTextLoader(documentId, loader, textOpt: null, mode: mode);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:Solution.cs

示例8: LoadTextAsync

        protected static async Task<TextAndVersion> LoadTextAsync(TextLoader loader, DocumentId documentId, SolutionServices services, bool reportInvalidDataException, CancellationToken cancellationToken)
        {
            int retries = 0;

            while (true)
            {
                try
                {
                    using (ExceptionHelpers.SuppressFailFast())
                    {
                        var result = await loader.LoadTextAndVersionAsync(services.Workspace, documentId, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
                        return result;
                    }
                }
                catch (OperationCanceledException)
                {
                    // if load text is failed due to a cancellation, make sure we propagate it out to the caller
                    throw;
                }
                catch (IOException e)
                {
                    if (++retries > MaxRetries)
                    {
                        services.Workspace.OnWorkspaceFailed(new DocumentDiagnostic(WorkspaceDiagnosticKind.Failure, e.Message, documentId));
                        return TextAndVersion.Create(SourceText.From(string.Empty, Encoding.UTF8), VersionStamp.Default, documentId.GetDebuggerDisplay());
                    }

                    // fall out to try again
                }
                catch (InvalidDataException e)
                {
                    // TODO: Adjust this behavior in the future if we add support for non-text additional files
                    if (reportInvalidDataException)
                    {
                        services.Workspace.OnWorkspaceFailed(new DocumentDiagnostic(WorkspaceDiagnosticKind.Failure, e.Message, documentId));
                    }

                    return TextAndVersion.Create(SourceText.From(string.Empty, Encoding.UTF8), VersionStamp.Default, documentId.GetDebuggerDisplay());
                }

                // try again after a delay
                await Task.Delay(RetryDelay).ConfigureAwait(false);
            }
        }
开发者ID:daking2014,项目名称:roslyn,代码行数:44,代码来源:TextDocumentState.cs

示例9: UpdateText

        public TextDocumentState UpdateText(TextLoader loader, PreservationMode mode)
        {
            if (loader == null)
            {
                throw new ArgumentNullException(nameof(loader));
            }

            // don't blow up on non-text documents.
            var newTextSource = (mode == PreservationMode.PreserveIdentity)
                ? CreateStrongText(loader, this.Id, this.solutionServices, reportInvalidDataException: false)
                : CreateRecoverableText(loader, this.Id, this.solutionServices, reportInvalidDataException: false);

            return new TextDocumentState(
                this.solutionServices,
                this.info,
                textSource: newTextSource);
        }
开发者ID:daking2014,项目名称:roslyn,代码行数:17,代码来源:TextDocumentState.cs

示例10: UpdateText

        public TextDocumentState UpdateText(TextLoader loader, PreservationMode mode)
        {
            if (loader == null)
            {
                throw new ArgumentNullException("loader");
            }

            var newTextSource = (mode == PreservationMode.PreserveIdentity)
                ? CreateStrongText(loader, this.Id, this.solutionServices)
                : CreateRecoverableText(loader, this.Id, this.solutionServices);

            return new TextDocumentState(
                this.solutionServices,
                this.info,
                textSource: newTextSource);
        }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:16,代码来源:TextDocumentState.cs

示例11: OnDocumentClosed

 public void OnDocumentClosed(DocumentId documentId, ITextBuffer textBuffer, TextLoader loader, bool updateActiveContext) { }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:1,代码来源:ServiceHubRemoteHostClient.WorkspaceHost.cs

示例12: OnAdditionalDocumentClosed

 public void OnAdditionalDocumentClosed(DocumentId documentId, ITextBuffer textBuffer, TextLoader loader) { }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:1,代码来源:ServiceHubRemoteHostClient.WorkspaceHost.cs

示例13: WithAdditionalDocumentTextLoader

        /// <summary>
        /// Creates a new solution instance with the additional document specified updated to have the text
        /// supplied by the text loader.
        /// </summary>
        public Solution WithAdditionalDocumentTextLoader(DocumentId documentId, TextLoader loader, PreservationMode mode)
        {
            var newState = _state.WithAdditionalDocumentTextLoader(documentId, loader, mode);
            if (newState == _state)
            {
                return this;
            }

            return new Solution(newState);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:14,代码来源:Solution.cs

示例14: WithDocumentTextLoader

        internal Solution WithDocumentTextLoader(DocumentId documentId, TextLoader loader, SourceText textOpt, PreservationMode mode)
        {
            var newState = _state.WithDocumentTextLoader(documentId, loader, textOpt, mode);
            if (newState == _state)
            {
                return this;
            }

            return new Solution(newState);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:10,代码来源:Solution.cs

示例15: DocumentInfo

 /// <summary>
 /// Create a new instance of a <see cref="DocumentInfo"/>.
 /// </summary>
 private DocumentInfo(DocumentAttributes attributes, TextLoader loader)
 {
     Attributes = attributes;
     TextLoader = loader;
 }
开发者ID:jkotas,项目名称:roslyn,代码行数:8,代码来源:DocumentInfo.cs


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