当前位置: 首页>>代码示例>>C#>>正文


C# ImmutableDictionary.ContainsKey方法代码示例

本文整理汇总了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;
 }
开发者ID:dotnet,项目名称:docfx,代码行数:8,代码来源:ExtractSearchIndex.cs

示例2: MethodCalledFromDispose

 private static bool MethodCalledFromDispose(ImmutableDictionary<INamedTypeSymbol, ImmutableHashSet<IMethodSymbol>> disposeMethodsCalledFromDispose, IMethodSymbol dispose)
 {
     return disposeMethodsCalledFromDispose.ContainsKey(dispose.ContainingType) &&
            disposeMethodsCalledFromDispose[dispose.ContainingType].Contains(dispose);
 }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:5,代码来源:DisposeNotImplementingDispose.cs

示例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;
        }
开发者ID:hbarve1,项目名称:roslyn,代码行数:21,代码来源:HostAnalyzerManager.cs

示例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);
        }
开发者ID:tvsonar,项目名称:roslyn,代码行数:11,代码来源:SolutionState.cs

示例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;
        }
开发者ID:holinov,项目名称:BitSharp,代码行数:32,代码来源:MainnetRules.cs

示例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));
 }
开发者ID:powermedia,项目名称:PowerMedia.Common,代码行数:11,代码来源:ImmutableCollectionsTests.cs


注:本文中的ImmutableDictionary.ContainsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。