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


C# ValueSource.GetValueAsync方法代码示例

本文整理汇总了C#中ValueSource.GetValueAsync方法的典型用法代码示例。如果您正苦于以下问题:C# ValueSource.GetValueAsync方法的具体用法?C# ValueSource.GetValueAsync怎么用?C# ValueSource.GetValueAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ValueSource的用法示例。


在下文中一共展示了ValueSource.GetValueAsync方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IncrementallyParseTreeAsync

        private static async Task<TreeAndVersion> IncrementallyParseTreeAsync(
            ValueSource<TreeAndVersion> oldTreeSource,
            ValueSource<TextAndVersion> newTextSource,
            CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FeatureId.DocumentState, FunctionId.DocumentState_IncrementallyParseSyntaxTree, cancellationToken))
            {
                var newTextAndVersion = await newTextSource.GetValueAsync(cancellationToken).ConfigureAwait(false);
                var newText = newTextAndVersion.Text;

                var oldTreeAndVersion = await oldTreeSource.GetValueAsync(cancellationToken).ConfigureAwait(false);
                var oldTree = oldTreeAndVersion.Tree;
                var oldText = await oldTree.GetTextAsync(cancellationToken).ConfigureAwait(false);

                var newTree = oldTree.WithChangedText(newText);
                Contract.ThrowIfNull(newTree);

                return MakeNewTreeAndVersion(oldTree, oldText, oldTreeAndVersion.Version, newTree, newText, newTextAndVersion.Version);
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:20,代码来源:DocumentState.cs

示例2: GetTextAndVersionAsync

        private static async Task<TextAndVersion> GetTextAndVersionAsync(
            ValueSource<TreeAndVersion> newTreeSource, VersionStamp version, Encoding encoding, string filePath, CancellationToken cancellationToken)
        {
            var treeAndVersion = await newTreeSource.GetValueAsync(cancellationToken).ConfigureAwait(false);
            var root = await treeAndVersion.Tree.GetRootAsync(cancellationToken).ConfigureAwait(false);

            return TextAndVersion.Create(root.GetText(encoding), version, filePath);
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:8,代码来源:DocumentState.cs

示例3: FullyParseTreeAsync

        private static async Task<TreeAndVersion> FullyParseTreeAsync(
            ValueSource<TextAndVersion> newTextSource,
            string filePath,
            ParseOptions options,
            HostLanguageServices languageServices,
            PreservationMode mode,
            CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FeatureId.DocumentState, FunctionId.DocumentState_FullyParseSyntaxTree, cancellationToken))
            {
                var textAndVersion = await newTextSource.GetValueAsync(cancellationToken).ConfigureAwait(false);
                var text = textAndVersion.Text;

                var treeFactory = languageServices.GetService<ISyntaxTreeFactoryService>();

                var tree = treeFactory.ParseSyntaxTree(filePath, options, text, cancellationToken);

                if (mode == PreservationMode.PreserveValue)
                {
                    var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);

                    // get a recoverable tree that reparses from the source text if it gets used after being kicked out of memory
                    tree = treeFactory.CreateRecoverableTree(tree.FilePath, tree.Options, newTextSource, root, reparse: true);
                }

                Contract.ThrowIfNull(tree);

                // text version for this document should be unique. use it as a starting point.
                return TreeAndVersion.Create(tree, textAndVersion.Version);
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:31,代码来源:DocumentState.cs

示例4: FullyParseTreeAsync

        private static async Task<TreeAndVersion> FullyParseTreeAsync(
            ValueSource<TextAndVersion> newTextSource,
            ProjectId cacheKey,
            string filePath,
            ParseOptions options,
            HostLanguageServices languageServices,
            SolutionServices solutionServices,
            PreservationMode mode,
            CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.Workspace_Document_State_FullyParseSyntaxTree, cancellationToken))
            {
                var textAndVersion = await newTextSource.GetValueAsync(cancellationToken).ConfigureAwait(false);
                var text = textAndVersion.Text;

                var treeFactory = languageServices.GetService<ISyntaxTreeFactoryService>();

                var tree = treeFactory.ParseSyntaxTree(filePath, options, text, cancellationToken);

                if (mode == PreservationMode.PreserveValue && solutionServices.SupportsCachingRecoverableObjects)
                {
                    var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);
                    tree = treeFactory.CreateRecoverableTree(cacheKey, tree.FilePath, tree.Options, newTextSource, root);
                }

                Contract.ThrowIfNull(tree);

                // text version for this document should be unique. use it as a starting point.
                return TreeAndVersion.Create(tree, textAndVersion.Version);
            }
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:31,代码来源:DocumentState.cs

示例5: IncrementallyParseTreeAsync

        private static async Task<TreeAndVersion> IncrementallyParseTreeAsync(
            ValueSource<TreeAndVersion> oldTreeSource,
            ValueSource<TextAndVersion> newTextSource,
            CancellationToken cancellationToken)
        {
            try
            {
                using (Logger.LogBlock(FunctionId.Workspace_Document_State_IncrementallyParseSyntaxTree, cancellationToken))
                {
                    var newTextAndVersion = await newTextSource.GetValueAsync(cancellationToken).ConfigureAwait(false);
                    var newText = newTextAndVersion.Text;

                    var oldTreeAndVersion = await oldTreeSource.GetValueAsync(cancellationToken).ConfigureAwait(false);
                    var oldTree = oldTreeAndVersion.Tree;
                    var oldText = await oldTree.GetTextAsync(cancellationToken).ConfigureAwait(false);

                    var newTree = oldTree.WithChangedText(newText);
                    Contract.ThrowIfNull(newTree);

                    return MakeNewTreeAndVersion(oldTree, oldText, oldTreeAndVersion.Version, newTree, newText, newTextAndVersion.Version);
                }
            }
            catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:27,代码来源:DocumentState.cs

示例6: IncrementallyParseTreeAsync

        private static async Task<TreeAndVersion> IncrementallyParseTreeAsync(
            ValueSource<TreeAndVersion> oldTreeSource,
            ValueSource<TextAndVersion> newTextSource,
            CancellationToken cancellationToken)
        {
            try
            {
                using (Logger.LogBlock(FunctionId.Workspace_Document_State_IncrementallyParseSyntaxTree, cancellationToken))
                {
                    var newTextAndVersion = await newTextSource.GetValueAsync(cancellationToken).ConfigureAwait(false);
                    var oldTreeAndVersion = await oldTreeSource.GetValueAsync(cancellationToken).ConfigureAwait(false);

                    return IncrementallyParse(newTextAndVersion, oldTreeAndVersion, cancellationToken);
                }
            }
            catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:20,代码来源:DocumentState.cs

示例7: FullyParseTreeAsync

 private static async Task<TreeAndVersion> FullyParseTreeAsync(
     ValueSource<TextAndVersion> newTextSource,
     ProjectId cacheKey,
     string filePath,
     ParseOptions options,
     HostLanguageServices languageServices,
     SolutionServices solutionServices,
     PreservationMode mode,
     CancellationToken cancellationToken)
 {
     using (Logger.LogBlock(FunctionId.Workspace_Document_State_FullyParseSyntaxTree, s_fullParseLog, filePath, mode, cancellationToken))
     {
         var textAndVersion = await newTextSource.GetValueAsync(cancellationToken).ConfigureAwait(false);
         return CreateTreeAndVersion(newTextSource, cacheKey, filePath, options, languageServices, mode, textAndVersion, cancellationToken);
     }
 }
开发者ID:jkotas,项目名称:roslyn,代码行数:16,代码来源:DocumentState.cs


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