本文整理汇总了C#中Jayrock.Json.JsonObject.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.GetEnumerator方法的具体用法?C# JsonObject.GetEnumerator怎么用?C# JsonObject.GetEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jayrock.Json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.GetEnumerator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NonGenericEnumeratorUsesSameEnumeratorAsGetEnumerator
public void NonGenericEnumeratorUsesSameEnumeratorAsGetEnumerator()
{
JsonObject obj = new JsonObject();
Assert.AreEqual(obj.GetEnumerator().GetType(), ((IEnumerable) obj).GetEnumerator().GetType());
}
示例2: KeyValuePairEnumeration
public void KeyValuePairEnumeration()
{
ICollection<KeyValuePair<string, object>> obj = new JsonObject();
KeyValuePair<string, object> first = new KeyValuePair<string, object>("first", 123);
obj.Add(first);
KeyValuePair<string, object> second = new KeyValuePair<string, object>("second", 456);
obj.Add(second);
using (IEnumerator<KeyValuePair<string, object>> e = obj.GetEnumerator())
{
Assert.IsNotNull(e);
Assert.IsTrue(e.MoveNext());
Assert.AreEqual(first, e.Current);
Assert.IsTrue(e.MoveNext());
Assert.AreEqual(second, e.Current);
Assert.IsFalse(e.MoveNext());
}
}
示例3: JsonMemberEnumeratorUsesSameEnumeratorAsGetEnumerator
public void JsonMemberEnumeratorUsesSameEnumeratorAsGetEnumerator()
{
JsonObject obj = new JsonObject();
Assert.AreEqual(obj.GetEnumerator().GetType(), ((IEnumerable<JsonMember>) obj).GetEnumerator().GetType());
}
示例4: Enumeration
public void Enumeration()
{
JsonObject o = new JsonObject();
o.Add("one", 1);
o.Add("two", 2);
o.Add("three", 3);
o.Add("four", 4);
JsonObject.JsonMemberEnumerator e = o.GetEnumerator();
Assert.IsNotNull(e);
Assert.IsTrue(e.MoveNext());
Assert.AreEqual("one", e.Current.Name);
Assert.AreEqual(1, e.Current.Value);
Assert.IsTrue(e.MoveNext());
Assert.AreEqual("two", e.Current.Name);
Assert.AreEqual(2, e.Current.Value);
Assert.IsTrue(e.MoveNext());
Assert.AreEqual("three", e.Current.Name);
Assert.AreEqual(3, e.Current.Value);
Assert.IsTrue(e.MoveNext());
Assert.AreEqual("four", e.Current.Name);
Assert.AreEqual(4, e.Current.Value);
Assert.IsFalse(e.MoveNext());
}
示例5: merge
private static void merge(JsonObject col, Hashtable hash)
{
IDictionaryEnumerator i = col.GetEnumerator();
i.MoveNext();
do
{
if (i.Value is JsonObject)
{
hash[i.Key] = JsonObjectToHash((JsonObject)i.Value);
}
else
hash[i.Key] = i.Value;
} while (i.MoveNext());
}
示例6: JsonObjectToHash
private static Hashtable JsonObjectToHash(JsonObject jo)
{
Hashtable hOut = new Hashtable();
IDictionaryEnumerator i = jo.GetEnumerator();
i.MoveNext();
do
{
hOut[i.Key.ToString()] = i.Value.ToString();
} while (i.MoveNext());
return hOut;
}