本文整理汇总了C#中System.Collections.Specialized.OrderedDictionary.GetObjectData方法的典型用法代码示例。如果您正苦于以下问题:C# OrderedDictionary.GetObjectData方法的具体用法?C# OrderedDictionary.GetObjectData怎么用?C# OrderedDictionary.GetObjectData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.OrderedDictionary
的用法示例。
在下文中一共展示了OrderedDictionary.GetObjectData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetObjectData
public void GetObjectData ()
{
OrderedDictionary coll = new OrderedDictionary (99);
coll.Add ("a", "1");
SerializationInfo si = new SerializationInfo (typeof (OrderedDictionary), new FormatterConverter ());
coll.GetObjectData (si, new StreamingContext ());
foreach (SerializationEntry se in si) {
switch (se.Name) {
case "KeyComparer":
Assert.IsNull (se.Value, se.Name);
break;
case "ReadOnly":
Assert.IsFalse ((bool) se.Value, se.Name);
break;
case "InitialCapacity":
Assert.AreEqual (99, se.Value, se.Name);
break;
case "ArrayList":
Assert.AreEqual ("1", ((DictionaryEntry)((object[]) se.Value)[0]).Value, se.Name);
break;
default:
string msg = String.Format ("Unexpected {0} information of type {1} with value '{2}'.",
se.Name, se.ObjectType, se.Value);
Assert.Fail (msg);
break;
}
}
}
示例2: GetObjectData_IEqualityComparer
public void GetObjectData_IEqualityComparer ()
{
EqualityComparer comparer = new EqualityComparer ();
OrderedDictionary coll = new OrderedDictionary (comparer);
coll.Add ("a", "1");
coll.Add ("b", "2");
coll = coll.AsReadOnly ();
SerializationInfo si = new SerializationInfo (typeof (OrderedDictionary), new FormatterConverter ());
coll.GetObjectData (si, new StreamingContext ());
foreach (SerializationEntry se in si) {
switch (se.Name) {
case "KeyComparer":
Assert.AreSame (comparer, se.Value, se.Name);
break;
case "ReadOnly":
Assert.IsTrue ((bool) se.Value, se.Name);
break;
case "InitialCapacity":
Assert.AreEqual (0, se.Value, se.Name);
break;
case "ArrayList":
Assert.AreEqual (2, ((object[]) se.Value).Length, se.Name);
break;
default:
string msg = String.Format ("Unexpected {0} information of type {1} with value '{2}'.",
se.Name, se.ObjectType, se.Value);
Assert.Fail (msg);
break;
}
}
}
示例3: GetObjectData_Null
public void GetObjectData_Null ()
{
OrderedDictionary coll = new OrderedDictionary ();
coll.GetObjectData (null, new StreamingContext ());
}