本文整理汇总了C#中ImmutableHashSet.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableHashSet.Contains方法的具体用法?C# ImmutableHashSet.Contains怎么用?C# ImmutableHashSet.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableHashSet
的用法示例。
在下文中一共展示了ImmutableHashSet.Contains方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldRunAnalyzerForStateType
private static bool ShouldRunAnalyzerForStateType(DiagnosticAnalyzer analyzer, StateType stateTypeId,
ImmutableHashSet<string> diagnosticIds = null, Func<DiagnosticAnalyzer, ImmutableArray<DiagnosticDescriptor>> getDescriptors = null)
{
if (diagnosticIds != null && getDescriptors(analyzer).All(d => !diagnosticIds.Contains(d.Id)))
{
return false;
}
switch (stateTypeId)
{
case StateType.Syntax:
return analyzer.SupportsSyntaxDiagnosticAnalysis();
case StateType.Document:
return analyzer.SupportsSemanticDiagnosticAnalysis();
case StateType.Project:
return analyzer.SupportsProjectDiagnosticAnalysis();
default:
throw ExceptionUtilities.Unreachable;
}
}
示例2: Filter
/// <summary>
/// Only the nodes that are in the <paramref name="includeNodes"/> set.
/// </summary>
public MetricsGossip Filter(ImmutableHashSet<Address> includeNodes)
{
return Copy(Nodes.Where(x => includeNodes.Contains(x.Address)).ToImmutableHashSet());
}
示例3: ShouldRunProviderForStateType
private static bool ShouldRunProviderForStateType(StateType stateTypeId, DiagnosticAnalyzer provider, DiagnosticAnalyzerDriver driver,
out bool supportsSemanticInSpan, ImmutableHashSet<string> diagnosticIds = null, Func<DiagnosticAnalyzer, ImmutableArray<DiagnosticDescriptor>> getDescriptor = null)
{
Debug.Assert(!IsAnalyzerSuppressed(provider, driver.Project.CompilationOptions, driver));
supportsSemanticInSpan = false;
if (diagnosticIds != null && getDescriptor(provider).All(d => !diagnosticIds.Contains(d.Id)))
{
return false;
}
switch (stateTypeId)
{
case StateType.Syntax:
return provider.SupportsSyntaxDiagnosticAnalysis(driver);
case StateType.Document:
return provider.SupportsSemanticDiagnosticAnalysis(driver, out supportsSemanticInSpan);
case StateType.Project:
return provider.SupportsProjectDiagnosticAnalysis(driver);
default:
throw ExceptionUtilities.Unreachable;
}
}
示例4: GetFilteredDiagnosticsAsync
private static async Task<ImmutableArray<Diagnostic>> GetFilteredDiagnosticsAsync(Task<IEnumerable<Diagnostic>> getDiagnosticsTask, ImmutableHashSet<string> diagnosticIds)
{
if (getDiagnosticsTask != null)
{
var diagnostics = await getDiagnosticsTask.ConfigureAwait(false);
if (diagnostics != null)
{
return diagnostics.Where(d => d != null && diagnosticIds.Contains(d.Id)).ToImmutableArray();
}
}
return ImmutableArray<Diagnostic>.Empty;
}
示例5: AddNonLocalDiagnostics
private static void AddNonLocalDiagnostics(
ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>> nonLocalDiagnostics,
ImmutableHashSet<DiagnosticAnalyzer> excludedAnalyzers,
ImmutableArray<Diagnostic>.Builder builder)
{
foreach (var diagnosticsByAnalyzer in nonLocalDiagnostics)
{
if (excludedAnalyzers.Contains(diagnosticsByAnalyzer.Key))
{
continue;
}
builder.AddRange(diagnosticsByAnalyzer.Value);
}
}
示例6: RemoveSymbolNamesFromSourceText
private static SourceText RemoveSymbolNamesFromSourceText(SourceText sourceText, ImmutableHashSet<string> linesToRemove)
{
if (linesToRemove.IsEmpty)
{
return sourceText;
}
HashSet<string> lines = GetLinesFromSourceText(sourceText);
var newLines = lines.Where(line => !linesToRemove.Contains(line));
IOrderedEnumerable<string> sortedLines = newLines.OrderBy(s => s, StringComparer.Ordinal);
SourceText newSourceText = sourceText.Replace(new TextSpan(0, sourceText.Length), string.Join(Environment.NewLine, sortedLines));
return newSourceText;
}
示例7: SatisfiesRole
private bool SatisfiesRole(ImmutableHashSet<string> memberRoles)
{
if (string.IsNullOrEmpty(Settings.UseRole)) return true;
return memberRoles.Contains(Settings.UseRole);
}
示例8: GetDiagnosticsForIdsAsync
public override async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForIdsAsync(Solution solution, ProjectId projectId = null, DocumentId documentId = null, ImmutableHashSet<string> diagnosticIds = null, CancellationToken cancellationToken = default(CancellationToken))
{
var diagnostics = await GetDiagnosticsAsync(solution, projectId, documentId, cancellationToken).ConfigureAwait(false);
return diagnostics.Where(d => diagnosticIds.Contains(d.Id)).ToImmutableArrayOrEmpty();
}
示例9: ShouldRunAnalyzerForStateTypeAsync
private static async Task<bool> ShouldRunAnalyzerForStateTypeAsync(DiagnosticAnalyzerDriver driver, DiagnosticAnalyzer analyzer, StateType stateTypeId,
ImmutableHashSet<string> diagnosticIds = null, Func<DiagnosticAnalyzer, ImmutableArray<DiagnosticDescriptor>> getDescriptors = null)
{
Debug.Assert(!driver.IsAnalyzerSuppressed(analyzer));
if (diagnosticIds != null && getDescriptors(analyzer).All(d => !diagnosticIds.Contains(d.Id)))
{
return false;
}
switch (stateTypeId)
{
case StateType.Syntax:
return await analyzer.SupportsSyntaxDiagnosticAnalysisAsync(driver).ConfigureAwait(false);
case StateType.Document:
return await analyzer.SupportsSemanticDiagnosticAnalysisAsync(driver).ConfigureAwait(false);
case StateType.Project:
return await analyzer.SupportsProjectDiagnosticAnalysisAsync(driver).ConfigureAwait(false);
default:
throw ExceptionUtilities.Unreachable;
}
}
示例10: IsFieldRelevant
private static bool IsFieldRelevant(IFieldSymbol fieldSymbol, ImmutableHashSet<IFieldSymbol> fieldsOfClass)
{
return fieldSymbol != null &&
!fieldSymbol.IsConst &&
!fieldSymbol.IsReadOnly &&
fieldsOfClass.Contains(fieldSymbol);
}
示例11: GetImmutable
private static ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>> GetImmutable(
ImmutableHashSet<DiagnosticAnalyzer> analyzers,
Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder> nonLocalDiagnosticsOpt)
{
if (nonLocalDiagnosticsOpt == null)
{
return ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>.Empty;
}
var builder = ImmutableDictionary.CreateBuilder<DiagnosticAnalyzer, ImmutableArray<Diagnostic>>();
foreach (var diagnosticsByAnalyzer in nonLocalDiagnosticsOpt)
{
if (analyzers.Contains(diagnosticsByAnalyzer.Key))
{
builder.Add(diagnosticsByAnalyzer.Key, diagnosticsByAnalyzer.Value.ToImmutable());
}
}
return builder.ToImmutable();
}
示例12: RemoveObservers
public Reachability RemoveObservers(ImmutableHashSet<UniqueAddress> nodes)
{
if (nodes.Count == 0)
{
return this;
}
else
{
var newRecords = _records.FindAll(r => !nodes.Contains(r.Observer));
if (newRecords.Count == _records.Count)
{
return this;
}
else
{
var newVersions = _versions.RemoveRange(nodes);
return new Reachability(newRecords, newVersions);
}
}
}