本文整理汇总了C#中ListDictionary.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# ListDictionary.ContainsKey方法的具体用法?C# ListDictionary.ContainsKey怎么用?C# ListDictionary.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListDictionary
的用法示例。
在下文中一共展示了ListDictionary.ContainsKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindSpriteNamesInAllScene
public static void FindSpriteNamesInAllScene()
{
ListDictionary<string, string> spriteNames = new ListDictionary<string, string>();
string[] scenes = (from scene in EditorBuildSettings.scenes where scene.enabled select scene.path).ToArray();
foreach (string scene in scenes)
{
EditorApplication.OpenScene(scene);
Transform[] allTrnasforms = GameObject.FindObjectsOfType<Transform>();
foreach (Transform transform in allTrnasforms)
{
UISprite sprite = transform.GetComponent<UISprite>();
if (sprite != null && !spriteNames.ContainsValue(scene, sprite.spriteName))
spriteNames.Add(scene, sprite.spriteName);
}
}
string log = string.Empty;
foreach (string scene in scenes)
{
if (!spriteNames.ContainsKey(scene))
continue;
log += string.Format("Scene : {0}\n", scene);
string spriteNameInScene = string.Empty;
foreach (string spriteName in spriteNames[scene])
spriteNameInScene += string.Format("{0}\n", spriteName);
log += string.Format("{0}\n\n", spriteNameInScene);
}
Debug.LogWarning(log);
}
示例2: ReadObject
private JsonObject ReadObject(ref char* ptr, ref char* end)
{
// check first letter
Debug.Assert(*ptr == '{');
ptr++;
// check object is empty
SkipWhitespaces(ref ptr, ref end);
if (IsEndOfJson(ref ptr, ref end))
{
// not completed
throw CreateException(ptr, "object is not closed.");
}
if (*ptr == '}')
{
ptr++;
return JsonObject.Empty;
}
IDictionary<string, JsonValue> dict = new ListDictionary<string, JsonValue>(SmallDictionaryLength);
int lest = SmallDictionaryLength;
while (true)
{
var keyBegin = ptr;
// read key
Assert(ref ptr, ref end, '\"');
var key = ReadObjectKey(ref ptr, ref end);
if (dict.ContainsKey(key))
{
throw CreateException(keyBegin, "duplicated key detected: " + key);
}
// read comma
SkipWhitespaces(ref ptr, ref end);
AssertAndReadNext(ref ptr, ':');
// read value and add to dictionary
dict.Add(key, ReadValue(ref ptr, ref end));
if (--lest == 0)
{
dict = ((ListDictionary<string, JsonValue>)dict).CreateDictionary();
}
// read close brace or comma
SkipWhitespaces(ref ptr, ref end);
if (IsEndOfJson(ref ptr, ref end))
{
// not completed
throw CreateException(ptr, "object is not closed.");
}
// if end of array, next letter should be ']'.
if (*ptr == '}')
{
// end of array
ptr++;
break;
}
// otherwise, next letter should be ','.
AssertAndReadNext(ref ptr, ',');
// skip while next string
SkipWhitespaces(ref ptr, ref end);
}
return new JsonObject(dict, true);
}