本文整理汇总了C#中ISet.AsEnumerable方法的典型用法代码示例。如果您正苦于以下问题:C# ISet.AsEnumerable方法的具体用法?C# ISet.AsEnumerable怎么用?C# ISet.AsEnumerable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISet
的用法示例。
在下文中一共展示了ISet.AsEnumerable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComplexifyParentingStatements
private static async Task<Tuple<SemanticDocument, ISet<ExpressionSyntax>>> ComplexifyParentingStatements(
SemanticDocument semanticDocument,
ISet<ExpressionSyntax> matches,
CancellationToken cancellationToken)
{
// First, track the matches so that we can get back to them later.
var newRoot = semanticDocument.Root.TrackNodes(matches);
var newDocument = semanticDocument.Document.WithSyntaxRoot(newRoot);
var newSemanticDocument = await SemanticDocument.CreateAsync(newDocument, cancellationToken).ConfigureAwait(false);
var newMatches = newSemanticDocument.Root.GetCurrentNodes(matches.AsEnumerable()).ToSet();
// Next, expand the topmost parenting expression of each match, being careful
// not to expand the matches themselves.
var topMostExpressions = newMatches
.Select(m => m.AncestorsAndSelf().OfType<ExpressionSyntax>().Last())
.Distinct();
newRoot = await newSemanticDocument.Root
.ReplaceNodesAsync(
topMostExpressions,
computeReplacementAsync: async (oldNode, newNode, ct) =>
{
return await Simplifier
.ExpandAsync(
oldNode,
newSemanticDocument.Document,
expandInsideNode: node =>
{
var expression = node as ExpressionSyntax;
return expression == null
|| !newMatches.Contains(expression);
},
cancellationToken: ct)
.ConfigureAwait(false);
},
cancellationToken: cancellationToken)
.ConfigureAwait(false);
newDocument = newSemanticDocument.Document.WithSyntaxRoot(newRoot);
newSemanticDocument = await SemanticDocument.CreateAsync(newDocument, cancellationToken).ConfigureAwait(false);
newMatches = newSemanticDocument.Root.GetCurrentNodes(matches.AsEnumerable()).ToSet();
return Tuple.Create(newSemanticDocument, newMatches);
}