Share via


AddressHeader.GetValue<T> Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

Syntax

'Declaration
Public Function GetValue(Of T) As T
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.

Return Value

Type: 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.

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.

Examples

The following example shows how to call this method.

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

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.