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)

Source:
AddressHeader.cs
Source:
AddressHeader.cs

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 T GetValue<T> (System.Runtime.Serialization.XmlObjectSerializer serializer);

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

.NET 8 (package-provided) and other versions
Product Versions
.NET Core 1.0, Core 1.1, 8 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
UWP 10.0

GetValue<T>()

Source:
AddressHeader.cs
Source:
AddressHeader.cs

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

public T GetValue<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>();

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

.NET 8 (package-provided) and other versions
Product Versions
.NET Core 1.0, Core 1.1, 8 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
UWP 10.0