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


C# Dict.ContainsKey方法代码示例

本文整理汇总了C#中Dict.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# Dict.ContainsKey方法的具体用法?C# Dict.ContainsKey怎么用?C# Dict.ContainsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dict的用法示例。


在下文中一共展示了Dict.ContainsKey方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GeneratorAssetbundleEntry

    static List<AssetBundleBuild> GeneratorAssetbundleEntry()
    {
        string path = Application.dataPath + "/" + PackagePlatform.packageConfigPath;
        if (string.IsNullOrEmpty(path)) return null;

        string str = File.ReadAllText(path);

        Dict<string, ABEntry> abEntries = new Dict<string, ABEntry>();

        PackageConfig apc = JsonUtility.FromJson<PackageConfig>(str);

        AssetBundlePackageInfo[] bundlesInfo = apc.bundles;

        for (int i = 0; i < bundlesInfo.Length; i++)
        {
            ABEntry entry = new ABEntry();
            entry.bundleInfo = bundlesInfo[i];

            if (!abEntries.ContainsKey(entry.bundleInfo.name))
            {
                abEntries.Add(entry.bundleInfo.name, entry);
            }
        }

        List<AssetBundleBuild> abbList = new List<AssetBundleBuild>();
        foreach (var rEntryItem in abEntries)
        {
            abbList.AddRange(rEntryItem.Value.ToABBuild());
        }
        return abbList;
    }
开发者ID:meta-42,项目名称:uEasyKit,代码行数:31,代码来源:AssetBundlePackage.cs

示例2: ItShouldAdd

 public void ItShouldAdd()
 {
     Dict<int, string> test = new Dict<int, string>();
     test.Add(1, "One");
     test.Add(2, "Two");
     test.Add(3, "Three");
     test.Add(4, "Four");
     test.Add(5, "Five");
     bool actual = test.ContainsKey(1);
     bool expected = true;
     Assert.AreEqual(expected, actual);
 }
开发者ID:bogdanuifalean,项目名称:JuniorMind,代码行数:12,代码来源:DictTest.cs

示例3: ItShouldRemove

 public void ItShouldRemove()
 {
     Dict<int, string> test = new Dict<int, string>();
     test.Add(1, "One");
     test.Add(2, "Two");
     test.Add(3, "Three");
     test.Add(4, "Four");
     test.Add(5, "Five");
     test.Add(18, "Eightteen");
     test.Remove(3);
     bool actual=test.ContainsKey(3);
     bool expected=false;
     Assert.AreEqual(expected, actual);
 }
开发者ID:bogdanuifalean,项目名称:JuniorMind,代码行数:14,代码来源:DictTest.cs

示例4: GetInitializedSlotValues

 /// <summary>
 /// Return a dict that maps slot names to slot values, but only include slots that have been assigned to.
 /// Looks up slots in base types as well as the current type.
 /// 
 /// Sort-of Python equivalent (doesn't look up base slots, while the real code does):
 ///   return dict([(slot, getattr(self, slot)) for slot in type(self).__slots__ if hasattr(self, slot)])
 /// 
 /// Return null if the object has no __slots__, or empty dict if it has __slots__ but none are initialized.
 /// </summary>
 private static Dict GetInitializedSlotValues(object obj)
 {
     Dict initializedSlotValues = new Dict();
     Tuple mro = Ops.GetDynamicType(obj).MethodResolutionOrder;
     object slots;
     object slotValue;
     foreach (object type in mro) {
         if (Ops.TryGetAttr(type, SymbolTable.Slots, out slots)) {
             List<string> slotNames = IronPython.Compiler.Generation.NewTypeMaker.SlotsToList(slots);
             foreach (string slotName in slotNames) {
                 if (slotName == "__dict__") continue;
                 // don't reassign same-named slots from types earlier in the MRO
                 if (initializedSlotValues.ContainsKey(slotName)) continue;
                 if (Ops.TryGetAttr(obj, SymbolTable.StringToId(slotName), out slotValue)) {
                     initializedSlotValues[slotName] = slotValue;
                 }
             }
         }
     }
     if (initializedSlotValues.Count == 0) return null;
     return initializedSlotValues;
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:31,代码来源:ObjectOps.cs

示例5: GetAttrDict

 internal IDictionary<object, object> GetAttrDict(ICallerContext context)
 {
     if (HaveInterfaces) {
         Dict res = new Dict();
         foreach (DynamicType type in interfaces) {
             Dict dict = type.GetAttrDict(context, obj);
             foreach (KeyValuePair<object, object> val in dict) {
                 if (!res.ContainsKey(val.Key)) {
                     res.Add(val);
                 }
             }
         }
         return res;
     } else {
         return new Dict(0);
     }
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:17,代码来源:ComObject.cs

示例6: FrozenSetCollection

 protected FrozenSetCollection(object set)
 {
     IEnumerator setData = Ops.GetEnumerator(set);
     items = new Dict();
     while (setData.MoveNext()) {
         object o = setData.Current;
         if (!items.ContainsKey(o)) {
             items.Add(o, o);
         }
     }
     CalculateHashCode();
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:12,代码来源:Set.cs

示例7: GetAttrDict

        public virtual Dict GetAttrDict(ICallerContext context, object self)
        {
            // Get the entries from the type
            Dict res = new Dict(GetAttrDict(context));

            // Add the entries from the instance
            ISuperDynamicObject sdo = self as ISuperDynamicObject;
            if (sdo != null) {
                IAttributesDictionary dict = sdo.GetDict();
                if (dict != null) {
                    foreach (KeyValuePair<object, object> val in dict) {
                        object fieldName = val.Key;
                        if (!res.ContainsKey(fieldName)) {
                            res.Add(new KeyValuePair<object, object>(fieldName, val.Value));
                        }
                    }
                }
            }
            return res;
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:20,代码来源:DynamicType.cs

示例8: Translate

 public static string Translate(string self, Dict table)
 {
     if (table == null) throw Ops.TypeError("expected dictionary or string, got NoneType");
     if (self.Length == 0) return self;
     StringBuilder ret = new StringBuilder();
     for (int i = 0, idx = 0; i < self.Length; i++) {
         idx = (int)self[i];
         if (table.ContainsKey(idx))
             ret.Append((string)table[idx]);
         else
             ret.Append(self[i]);
     }
     return ret.ToString();
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:14,代码来源:StringOps.cs

示例9: GetPageMetaInfo

        /// <summary>
        /// Extracts the meta tag info from the page using RegEx
        /// </summary>
        /// <param name="p_strPageHtmlContent"></param>
        /// <returns>Deprecated</returns>
        private static Dict<string, PageMeta> GetPageMetaInfo(string p_strPageHtmlContent)
        {
            Dict<string, PageMeta> dictReturnSet = new Dict<string, PageMeta>();
            PageMeta pmMetaTag = new PageMeta();

            //   Try grabbing the meta info of the page into a dictionary
            string pattern = "<meta.+?(?:name=(?:\"|')(.*?)(?:\"|').*?)?(?:property=(?:\"|')(.*?)(?:\"|').*?)?(?:content=(?:\"|')(.*?)(?:\"|'))?/?>.*?</head>";
            RegexOptions rxoOptions = RegexOptions.IgnoreCase | RegexOptions.Singleline;

            foreach (Match match in Regex.Matches(p_strPageHtmlContent, pattern, rxoOptions))
            {
                pmMetaTag = new PageMeta();
                pmMetaTag.Name = match.Groups[1].Value;
                pmMetaTag.Property = match.Groups[2].Value;
                pmMetaTag.Content = match.Groups[3].Value;
                if (!dictReturnSet.ContainsKey(match.Groups[1].Value))
                {
                    dictReturnSet.Add(match.Groups[1].Value, pmMetaTag);
                }
            }

            return dictReturnSet;
        }
开发者ID:Green-Orca,项目名称:WebStuffCore,代码行数:28,代码来源:SiteCrawler.cs


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