DataContractFormatAttribute Klasa

Definicja

Instruuje infrastrukturę Windows Communication Foundation (WCF), aby korzystała z programu DataContractSerializer.

public ref class DataContractFormatAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)]
public sealed class DataContractFormatAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface | System.AttributeTargets.Method, Inherited=false)]
public sealed class DataContractFormatAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)>]
type DataContractFormatAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface | System.AttributeTargets.Method, Inherited=false)>]
type DataContractFormatAttribute = class
    inherit Attribute
Public NotInheritable Class DataContractFormatAttribute
Inherits Attribute
Dziedziczenie
DataContractFormatAttribute
Atrybuty

Przykłady

Poniższy przykład stosuje właściwość DataContractFormatAttribute i ustawia Style właściwość na Rpcwartość . Styl RPC jest opisany w specyfikacji języka opisu usługi sieci Web (WSDL).

[ServiceContract, DataContractFormat(Style = OperationFormatStyle.Rpc)]
interface ICalculator
{
    [OperationContract, DataContractFormat(Style = OperationFormatStyle.Rpc)]
    double Add(double a, double b);

    [OperationContract, DataContractFormat(Style = OperationFormatStyle.Document)]
    double Subtract(double a, double b);
}
<ServiceContract(), DataContractFormat(Style := OperationFormatStyle.Rpc)>  _
Interface ICalculator
    <OperationContract(), DataContractFormat(Style := OperationFormatStyle.Rpc)>  _
    Function Add(ByVal a As Double, ByVal b As Double) As Double 
    
    <OperationContract(), DataContractFormat(Style := OperationFormatStyle.Document)>  _
    Function Subtract(ByVal a As Double, ByVal b As Double) As Double 
End Interface
<ServiceContract(), DataContractFormat(Style := OperationFormatStyle.Rpc)>  _
Interface ICalculator
    <OperationContract(), DataContractFormat(Style := OperationFormatStyle.Rpc)>  _
    Function Add(ByVal a As Double, ByVal b As Double) As Double 
    
    <OperationContract(), DataContractFormat(Style := OperationFormatStyle.Document)>  _
    Function Subtract(ByVal a As Double, ByVal b As Double) As Double 
End Interface

Uwagi

Ten atrybut jest podobny do atrybutu XmlSerializerFormatAttribute . Oba atrybuty można zastosować do metody lub klasy.

Metoda może mieć zastosowanie jednego z dwóch atrybutów, ale nie obu. Każda operacja, która nie została zastosowana, będzie używać atrybutu zastosowanego do klasy zawierającej. Jeśli klasa zawierająca nie ma zastosowanego atrybutu, DataContractSerializer jest używany.

Zastosowanie atrybutu powoduje również utworzenie elementu DataContractSerializerOperationBehavior w czasie wykonywania. Zachowanie umożliwia dostosowanie w czasie wykonywania zachowania serializatora.

Konstruktory

DataContractFormatAttribute()

Inicjuje nowe wystąpienie klasy DataContractFormatAttribute.

Właściwości

Style

Pobiera lub ustawia styl SOAP serializowanych danych.

TypeId

Po zaimplementowaniu w klasie pochodnej pobiera unikatowy identyfikator dla tego Attributeelementu .

(Odziedziczone po Attribute)

Metody

Equals(Object)

Zwraca wartość wskazującą, czy to wystąpienie jest równe podanemu obiektowi.

(Odziedziczone po Attribute)
GetHashCode()

Zwraca wartość skrótu dla tego wystąpienia.

(Odziedziczone po Attribute)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
IsDefaultAttribute()

W przypadku zastąpienia w klasie pochodnej wskazuje, czy wartość tego wystąpienia jest wartością domyślną klasy pochodnej.

(Odziedziczone po Attribute)
Match(Object)

Po przesłonięciu w klasie pochodnej zwraca wartość wskazującą, czy to wystąpienie jest równe określonemu obiektowi.

(Odziedziczone po Attribute)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Zestaw nazw jest mapowany na odpowiedni zestaw identyfikatorów wysyłania.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Pobiera informacje o typie dla obiektu, który może służyć do pobierania informacji o typie dla interfejsu.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Pobiera informację o liczbie typów interfejsów, jakie zawiera obiekt (0 lub 1).

(Odziedziczone po Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Umożliwia dostęp do właściwości i metod udostępnianych przez obiekt.

(Odziedziczone po Attribute)

Dotyczy

Zobacz też