本文整理汇总了C#中IImmutableSet.Where方法的典型用法代码示例。如果您正苦于以下问题:C# IImmutableSet.Where方法的具体用法?C# IImmutableSet.Where怎么用?C# IImmutableSet.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IImmutableSet
的用法示例。
在下文中一共展示了IImmutableSet.Where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryHandleCommandAsync
public async Task<bool> TryHandleCommandAsync(IImmutableSet<IProjectTree> nodes, long commandId, bool focused, long commandExecuteOptions, IntPtr variantArgIn, IntPtr variantArgOut) {
if (!_commandIds.Contains(commandId)) {
return false;
}
var rDataNode = nodes.Where(IsRData).LastOrDefault();
if (rDataNode == null) {
return false;
}
return await TryHandleCommandAsyncInternal(rDataNode);
}
示例2: ExcludePrivateFieldsBasedOnCompilerErrors
private static void ExcludePrivateFieldsBasedOnCompilerErrors(
IImmutableDictionary<ISymbol, PrivateField> privateFields,
IDictionary<ISymbol, IDictionary<SyntaxNode, ISymbol>> referencesByEnclosingSymbol,
IImmutableSet<ISymbol> classMethods,
TypeDeclarationSyntax classNode)
{
var replacements = new Dictionary<SyntaxNode, BlockSyntax>();
foreach (var classMethod in classMethods.Where(m => referencesByEnclosingSymbol.ContainsKey(m)))
{
var references = referencesByEnclosingSymbol[classMethod].Where(r => !privateFields[r.Value].Excluded).ToImmutableDictionary(kv => kv.Key, kv => kv.Value);
BlockSyntax body;
BlockSyntax newBody;
if (TryRewriteMethodBody(privateFields, references, classMethod, out body, out newBody))
{
replacements.Add(body, newBody);
}
}
if (!replacements.Any())
{
return;
}
var newSyntaxRoot = classNode.SyntaxTree.GetRoot().ReplaceSyntax(
replacements.Keys,
(original, partiallyRewritten) => replacements[original],
null,
null,
null,
null);
var newSyntaxTree = classNode.SyntaxTree.WithRootAndOptions(newSyntaxRoot, classNode.SyntaxTree.Options);
var newCompilation = CSharpCompilation.Create(nameof(PrivateFieldUsedAsLocalVariable), new[] { newSyntaxTree });
var diagnostics = newCompilation.GetDiagnostics();
foreach (var privateField in privateFields.Values.Where(f => !f.Excluded))
{
if (diagnostics.Any(d => d.Id == WellKnownDiagnosticIds.ERR_UseDefViolation && d.GetMessage().Contains(privateField.UniqueName)))
{
privateField.Excluded = true;
}
}
}