當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。