本文整理汇总了C#中ImmutableDictionary.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableDictionary.ContainsKey方法的具体用法?C# ImmutableDictionary.ContainsKey怎么用?C# ImmutableDictionary.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableDictionary
的用法示例。
在下文中一共展示了ImmutableDictionary.ContainsKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareMetadata
public ImmutableDictionary<string, object> PrepareMetadata(ImmutableDictionary<string, object> metadata)
{
if (!metadata.ContainsKey("_enableSearch"))
{
metadata = metadata.Add("_enableSearch", true);
}
return metadata;
}
示例2: MethodCalledFromDispose
private static bool MethodCalledFromDispose(ImmutableDictionary<INamedTypeSymbol, ImmutableHashSet<IMethodSymbol>> disposeMethodsCalledFromDispose, IMethodSymbol dispose)
{
return disposeMethodsCalledFromDispose.ContainsKey(dispose.ContainingType) &&
disposeMethodsCalledFromDispose[dispose.ContainingType].Contains(dispose);
}
示例3: MergeDiagnosticAnalyzerMap
private static ImmutableDictionary<object, ImmutableArray<DiagnosticAnalyzer>> MergeDiagnosticAnalyzerMap(
ImmutableDictionary<object, ImmutableArray<DiagnosticAnalyzer>> map1, ImmutableDictionary<object, ImmutableArray<DiagnosticAnalyzer>> map2)
{
var current = map1;
var seen = new HashSet<DiagnosticAnalyzer>(map1.Values.SelectMany(v => v));
foreach (var kv in map2)
{
var referenceIdentity = kv.Key;
var analyzers = kv.Value;
if (map1.ContainsKey(referenceIdentity))
{
continue;
}
current = current.Add(referenceIdentity, analyzers.Where(a => seen.Add(a)).ToImmutableArray());
}
return current;
}
示例4: CreateDependencyGraph
private static ProjectDependencyGraph CreateDependencyGraph(
IReadOnlyList<ProjectId> projectIds,
ImmutableDictionary<ProjectId, ProjectState> projectStates)
{
var map = projectStates.Values.Select(state => new KeyValuePair<ProjectId, ImmutableHashSet<ProjectId>>(
state.Id,
state.ProjectReferences.Where(pr => projectStates.ContainsKey(pr.ProjectId)).Select(pr => pr.ProjectId).ToImmutableHashSet()))
.ToImmutableDictionary();
return new ProjectDependencyGraph(projectIds.ToImmutableArray(), map);
}
示例5: GetPreviousTransaction
private Transaction GetPreviousTransaction(Block block, int txIndex, TxOutputKey prevTxOutputKey, ImmutableDictionary<UInt256, UnspentTx> utxo, ImmutableDictionary<UInt256, ImmutableHashSet<int>> newTransactions)
{
if (newTransactions.ContainsKey(prevTxOutputKey.TxHash))
{
var eligible = newTransactions[prevTxOutputKey.TxHash].Where(x => x < txIndex).ToList();
if (eligible.Count > 0)
{
var max = eligible.Max();
if (max >= block.Transactions.Length)
throw new Exception();
var prevTx1 = block.Transactions[max];
if (prevTx1.Hash != prevTxOutputKey.TxHash)
throw new Exception();
return prevTx1;
}
}
// find previous transaction
if (!utxo.ContainsKey(prevTxOutputKey.TxHash))
throw new MissingDataException(DataType.Transaction, prevTxOutputKey.TxHash);
var prevTxKey = utxo[prevTxOutputKey.TxHash].ToTxKey();
var prevTx2 = this.CacheContext.GetTransaction(prevTxKey);
if (prevTx2.Hash != prevTxOutputKey.TxHash)
throw new Exception();
return prevTx2;
}
示例6: ContainsKey_Test
public void ContainsKey_Test()
{
Dictionary<int, string> _dictionary = new Dictionary<int, string>
{
{1, "aabb"},
{2, "bbcc"},
{3, "ccdd"}
};
ImmutableDictionary<int, string> _immutableDictionary = new ImmutableDictionary<int, string>(_dictionary);
Assert.IsTrue(_immutableDictionary.ContainsKey(1));
}