本文整理匯總了C#中System.Runtime.Serialization.SerializationInfo.IsNull方法的典型用法代碼示例。如果您正苦於以下問題:C# SerializationInfo.IsNull方法的具體用法?C# SerializationInfo.IsNull怎麽用?C# SerializationInfo.IsNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Runtime.Serialization.SerializationInfo
的用法示例。
在下文中一共展示了SerializationInfo.IsNull方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetObjectData
public override void GetObjectData(
SerializationInfo serializationInfo, StreamingContext streamingContext)
{
if (serializationInfo.IsNull ())
throw new ArgumentNullException ("serializationInfo");
serializationInfo.AddValue ("InternallyCreated", internallyCreated);
serializationInfo.AddValue ("State", (int) state);
int count = Count;
serializationInfo.AddValue ("Count", count);
count.Times (i => {
serializationInfo.AddValue (i.ToString (), GetKey (i));
serializationInfo.AddValue ((count + i).ToString (), Get (i));
});
}
示例2: WebHeaderCollection
/// <summary>
/// Initializes a new instance of the <see cref="WebHeaderCollection"/> class
/// with the specified <see cref="SerializationInfo"/> and <see cref="StreamingContext"/>.
/// </summary>
/// <param name="serializationInfo">
/// A <see cref="SerializationInfo"/> that contains the data to need to serialize the <see cref="WebHeaderCollection"/> object.
/// </param>
/// <param name="streamingContext">
/// A <see cref="StreamingContext"/> that contains the source of the serialized stream associated with the new <see cref="WebHeaderCollection"/>.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="serializationInfo"/> is <see langword="null"/>.
/// </exception>
/// <exception cref="ArgumentException">
/// An element with the specified name is not found in <paramref name="serializationInfo"/>.
/// </exception>
protected WebHeaderCollection(
SerializationInfo serializationInfo, StreamingContext streamingContext)
{
if (serializationInfo.IsNull ())
throw new ArgumentNullException ("serializationInfo");
try {
internallyCreated = serializationInfo.GetBoolean ("InternallyCreated");
state = (HttpHeaderType) serializationInfo.GetInt32 ("State");
int count = serializationInfo.GetInt32 ("Count");
count.Times (i => {
base.Add (
serializationInfo.GetString (i.ToString ()),
serializationInfo.GetString ((count + i).ToString ()));
});
} catch (SerializationException ex) {
throw new ArgumentException (ex.Message, "serializationInfo", ex);
}
}