SerializationGetOrDefaultT Method

Gets SerializationInfo value for specified name; otherwise defaultValue.

Definition

Namespace: Gemstone
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.128 -- Release Build+d050cfc5563c89a1188cc3c6b2d417530856f490
public static T GetOrDefault<T>(
	this SerializationInfo info,
	string name,
	T defaultValue
)

Parameters

info  SerializationInfo
SerializationInfo object that contains deserialized values.
name  String
Name of deserialized parameter to retrieve.
defaultValue  T
Default value to return if name does not exist or cannot be deserialized.

Type Parameters

T
Type of parameter to get from SerializationInfo.

Return Value

T
Value for specified name; otherwise defaultValue

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type SerializationInfo. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

SerializationInfo do not have a direct way of determining if an item with a specified name exists, so when calling one of the Get(n) functions you will simply get a SerializationException if the parameter does not exist; similarly you will receive this exception if the parameter fails to properly deserialize. This extension method protects against both of these failures and returns a default value if the named parameter does not exist or cannot be deserialized.

See Also