本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}