AddressHeader.GetValue Method

Definition

Deserializes the information item from the current address header object.

Overloads

GetValue<T>(XmlObjectSerializer)

Deserializes the information item from the current address header to an object of a specified type that uses a specified formatter to serialize this information.

GetValue<T>()

Deserializes the information item from the current address header to an object of a specified type.

Remarks

Use the GetValue<T>(XmlObjectSerializer) overload if you want to use a customized XML formatter; otherwise use the GetValue<T>() overload.

GetValue<T>(XmlObjectSerializer)

Deserializes the information item from the current address header to an object of a specified type that uses a specified formatter to serialize this information.

public:
generic <typename T>
 T GetValue(System::Runtime::Serialization::XmlObjectSerializer ^ serializer);
public T GetValue<T> (System.Runtime.Serialization.XmlObjectSerializer serializer);
member this.GetValue : System.Runtime.Serialization.XmlObjectSerializer -> 'T
Public Function GetValue(Of T) (serializer As XmlObjectSerializer) As T

Type Parameters

T

A class of type T with its fields and properties set to the values supplied by the current address header object.

Parameters

serializer
XmlObjectSerializer

The XmlObjectSerializer used to deserialize the information item from the current address header object.

Returns

T

An instance of a class of type T with its fields and properties set to the values supplied by the current address header object.

Exceptions

The serializer is null.

Examples

The following example shows how to call this method.

Remarks

When using this overload, you must supply a type for the generic parameter T. The type of the return value is determined by the generic type parameter.

Use this overload only if you want to use a customized XML formatter; otherwise use the GetValue<T>() overload.

Applies to

GetValue<T>()

Deserializes the information item from the current address header to an object of a specified type.

public:
generic <typename T>
 T GetValue();
public T GetValue<T> ();
member this.GetValue : unit -> 'T
Public Function GetValue(Of T) () As T

Type Parameters

T

A class of type T with its fields and properties set to the values supplied by the current address header object.

Returns

T

An instance of a class of type T with its fields and properties set to the values supplied by the current address header object.

Examples

The following example shows how to call this method.

//Create address headers with XmlObjectSerializer specified
XmlObjectSerializer serializer = new DataContractSerializer(typeof(int));
AddressHeader addressHeaderWithObjSer = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service", 1, serializer);
int value = addressHeaderWithObjSer.GetValue<int>();
//Create address headers with XmlObjectSerializer specified
XmlObjectSerializer serializer = new DataContractSerializer(typeof(int));
AddressHeader addressHeaderWithObjSer = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service", 1, serializer);
int value = addressHeaderWithObjSer.GetValue<int>();
'Create address headers with XmlObjectSerializer specified
Dim serializer As XmlObjectSerializer = New DataContractSerializer(GetType(Integer))
Dim addressHeaderWithObjSer As AddressHeader = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service", 1, serializer)
Dim value As Integer = addressHeaderWithObjSer.GetValue(Of Integer)()
'Create address headers with XmlObjectSerializer specified
Dim serializer As XmlObjectSerializer = New DataContractSerializer(GetType(Integer))
Dim addressHeaderWithObjSer As AddressHeader = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service", 1, serializer)
Dim value As Integer = addressHeaderWithObjSer.GetValue(Of Integer)()

Remarks

When using this overload, you must supply a type for the generic parameter T. The type of the return value is determined by the generic type parameter.

Use the GetValue<T>(XmlObjectSerializer) overload if you want to use a customized XML formatter.

Applies to