Sdílet prostřednictvím


AddressHeader.CreateAddressHeader Metoda

Definice

Vytvoří novou instanci třídy AddressHeader.

Přetížení

CreateAddressHeader(Object)

Vytvoří novou instanci AddressHeader třídy se zadanou hodnotou.

CreateAddressHeader(Object, XmlObjectSerializer)

Vytvoří novou instanci AddressHeader třídy pomocí zadaného formátovače pro serializaci položky informací ze zadaného objektu.

CreateAddressHeader(String, String, Object)

Vytvoří novou instanci AddressHeader třídy se zadanou hodnotou, názvem a oborem názvů.

CreateAddressHeader(String, String, Object, XmlObjectSerializer)

Vytvoří novou instanci AddressHeader třídy se zadaným názvem a oborem názvů, který používá zadaný formátovací modul k serializaci položky informací ze zadaného objektu.

Poznámky

Objekt, který obsahuje položku informace je serializován do hlavičky adresy objektem XmlObjectSerializer .

CreateAddressHeader(Object)

Zdroj:
AddressHeader.cs
Zdroj:
AddressHeader.cs
Zdroj:
AddressHeader.cs

Vytvoří novou instanci AddressHeader třídy se zadanou hodnotou.

public:
 static System::ServiceModel::Channels::AddressHeader ^ CreateAddressHeader(System::Object ^ value);
public static System.ServiceModel.Channels.AddressHeader CreateAddressHeader (object value);
static member CreateAddressHeader : obj -> System.ServiceModel.Channels.AddressHeader
Public Shared Function CreateAddressHeader (value As Object) As AddressHeader

Parametry

value
Object

Položka informací pro hlavičku adresy.

Návraty

Položka AddressHeader , která obsahuje položku informací určenou parametrem value .

Příklady

Následující příklad ukazuje, jak vytvořit hlavičku adresy pomocí této metody.

// Obsolete
// Obsolete
' Obsolete
' Obsolete

Platí pro

CreateAddressHeader(Object, XmlObjectSerializer)

Zdroj:
AddressHeader.cs
Zdroj:
AddressHeader.cs
Zdroj:
AddressHeader.cs

Vytvoří novou instanci AddressHeader třídy pomocí zadaného formátovače pro serializaci položky informací ze zadaného objektu.

public:
 static System::ServiceModel::Channels::AddressHeader ^ CreateAddressHeader(System::Object ^ value, System::Runtime::Serialization::XmlObjectSerializer ^ serializer);
public static System.ServiceModel.Channels.AddressHeader CreateAddressHeader (object value, System.Runtime.Serialization.XmlObjectSerializer serializer);
static member CreateAddressHeader : obj * System.Runtime.Serialization.XmlObjectSerializer -> System.ServiceModel.Channels.AddressHeader
Public Shared Function CreateAddressHeader (value As Object, serializer As XmlObjectSerializer) As AddressHeader

Parametry

value
Object

Položka informací pro hlavičku adresy.

serializer
XmlObjectSerializer

Slouží XmlObjectSerializer k serializaci zadaného objektu v parametru value .

Návraty

Položka AddressHeader obsahující položku informací určenou parametrem value.

Výjimky

Hodnota formatter je null.

Příklady

Následující příklad ukazuje, jak vytvořit hlavičku adresy pomocí této metody.

// Obsolete
// Obsolete
' Obsolete
' Obsolete

Platí pro

CreateAddressHeader(String, String, Object)

Zdroj:
AddressHeader.cs
Zdroj:
AddressHeader.cs
Zdroj:
AddressHeader.cs

Vytvoří novou instanci AddressHeader třídy se zadanou hodnotou, názvem a oborem názvů.

public:
 static System::ServiceModel::Channels::AddressHeader ^ CreateAddressHeader(System::String ^ name, System::String ^ ns, System::Object ^ value);
public static System.ServiceModel.Channels.AddressHeader CreateAddressHeader (string name, string ns, object value);
static member CreateAddressHeader : string * string * obj -> System.ServiceModel.Channels.AddressHeader
Public Shared Function CreateAddressHeader (name As String, ns As String, value As Object) As AddressHeader

Parametry

name
String

Název hlavičky adresy.

ns
String

Obor názvů hlavičky adresy.

value
Object

Položka informací pro hlavičku adresy.

Návraty

Se AddressHeader zadaným name a ns obsahujícím položku informací určenou nástrojem value.

Výjimky

Hodnota name je null nebo name. Délka == 0.

Příklady

Následující příklad ukazuje, jak vytvořit hlavičku adresy pomocí této metody.

// Create address headers for special services and add them to an array
AddressHeader addressHeader1 = AddressHeader.CreateAddressHeader("specialservice1", "http://localhost:8000/service", 1);
AddressHeader addressHeader2 = AddressHeader.CreateAddressHeader("specialservice2", "http://localhost:8000/service", 2);
AddressHeader[] addressHeaders = new AddressHeader[2] { addressHeader1, addressHeader2 };

// Endpoint address constructor with URI and address headers
EndpointAddress endpointAddressWithHeaders = new EndpointAddress(
    new Uri("http://localhost/silverlightsamples/service1"), addressHeaders
    );

// Confirm adddressHeader1 is in endpointAddressWithHeaders - boolHeaders returns True.
AddressHeaderCollection addressHeaderCollection = endpointAddressWithHeaders.Headers;
bool boolHeaders = addressHeaderCollection.Contains(addressHeader1);
// Create address headers for special services and add them to an array
AddressHeader addressHeader1 = AddressHeader.CreateAddressHeader("specialservice1", "http://localhost:8000/service", 1);
AddressHeader addressHeader2 = AddressHeader.CreateAddressHeader("specialservice2", "http://localhost:8000/service", 2);
AddressHeader[] addressHeaders = new AddressHeader[2] { addressHeader1, addressHeader2 };

// Endpoint address constructor with URI and address headers
EndpointAddress endpointAddressWithHeaders = new EndpointAddress(
    new Uri("http://localhost/silverlightsamples/service1"), addressHeaders
    );

// Confirm adddressHeader1 is in endpointAddressWithHeaders - boolHeaders returns True.
AddressHeaderCollection addressHeaderCollection = endpointAddressWithHeaders.Headers;
bool boolHeaders = addressHeaderCollection.Contains(addressHeader1);
' Create address headers for special services and add them to an array
Dim addressHeader1 As AddressHeader = AddressHeader.CreateAddressHeader("specialservice1", "http://localhost:8000/service", 1)
Dim addressHeader2 As AddressHeader = AddressHeader.CreateAddressHeader("specialservice2", "http://localhost:8000/service", 2)
Dim addressHeaders() As AddressHeader = { addressHeader1, addressHeader2 }

' Endpoint address constructor with URI and address headers
Dim endpointAddressWithHeaders As New EndpointAddress(New Uri("http://localhost/silverlightsamples/service1"), addressHeaders)

' Confirm adddressHeader1 is in endpointAddressWithHeaders - boolHeaders returns True.
Dim addressHeaderCollection As AddressHeaderCollection = endpointAddressWithHeaders.Headers
Dim boolHeaders As Boolean = addressHeaderCollection.Contains(addressHeader1)
' Create address headers for special services and add them to an array
Dim addressHeader1 As AddressHeader = AddressHeader.CreateAddressHeader("specialservice1", "http://localhost:8000/service", 1)
Dim addressHeader2 As AddressHeader = AddressHeader.CreateAddressHeader("specialservice2", "http://localhost:8000/service", 2)
Dim addressHeaders() As AddressHeader = { addressHeader1, addressHeader2 }

' Endpoint address constructor with URI and address headers
Dim endpointAddressWithHeaders As New EndpointAddress(New Uri("http://localhost/silverlightsamples/service1"), addressHeaders)

' Confirm adddressHeader1 is in endpointAddressWithHeaders - boolHeaders returns True.
Dim addressHeaderCollection As AddressHeaderCollection = endpointAddressWithHeaders.Headers
Dim boolHeaders As Boolean = addressHeaderCollection.Contains(addressHeader1)

Platí pro

CreateAddressHeader(String, String, Object, XmlObjectSerializer)

Zdroj:
AddressHeader.cs
Zdroj:
AddressHeader.cs
Zdroj:
AddressHeader.cs

Vytvoří novou instanci AddressHeader třídy se zadaným názvem a oborem názvů, který používá zadaný formátovací modul k serializaci položky informací ze zadaného objektu.

public:
 static System::ServiceModel::Channels::AddressHeader ^ CreateAddressHeader(System::String ^ name, System::String ^ ns, System::Object ^ value, System::Runtime::Serialization::XmlObjectSerializer ^ serializer);
public static System.ServiceModel.Channels.AddressHeader CreateAddressHeader (string name, string ns, object value, System.Runtime.Serialization.XmlObjectSerializer serializer);
static member CreateAddressHeader : string * string * obj * System.Runtime.Serialization.XmlObjectSerializer -> System.ServiceModel.Channels.AddressHeader
Public Shared Function CreateAddressHeader (name As String, ns As String, value As Object, serializer As XmlObjectSerializer) As AddressHeader

Parametry

name
String

Název hlavičky adresy.

ns
String

Obor názvů hlavičky adresy.

value
Object

Položka informací pro hlavičku adresy.

serializer
XmlObjectSerializer

Slouží XmlObjectSerializer k serializaci zadaného objektu v parametru value .

Návraty

Se AddressHeader zadaným name a ns obsahujícím položku informací určenou nástrojem value.

Výjimky

name nebo serializer je null nebo name. Délka == 0.

Příklady

Následující příklad ukazuje, jak vytvořit hlavičku adresy pomocí této metody.

//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)()

Platí pro