當前位置: 首頁>>代碼示例>>C#>>正文


C# OrderedDictionary.GetObjectData方法代碼示例

本文整理匯總了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;
				}
			}
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:29,代碼來源:OrderedDictionaryTest.cs

示例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;
				}
			}
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:32,代碼來源:OrderedDictionaryTest.cs

示例3: GetObjectData_Null

		public void GetObjectData_Null ()
		{
			OrderedDictionary coll = new OrderedDictionary ();
			coll.GetObjectData (null, new StreamingContext ());
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:5,代碼來源:OrderedDictionaryTest.cs


注:本文中的System.Collections.Specialized.OrderedDictionary.GetObjectData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。