Поделиться через


DeliveryRequirementsAttribute Класс

Определение

Определяет требования к характеристикам, которые привязки обязаны предоставлять службе или реализации клиента.

public ref class DeliveryRequirementsAttribute sealed : Attribute, System::ServiceModel::Description::IContractBehavior
public ref class DeliveryRequirementsAttribute sealed : Attribute, System::ServiceModel::Description::IContractBehavior, System::ServiceModel::Description::IContractBehaviorAttribute
public sealed class DeliveryRequirementsAttribute : Attribute, System.ServiceModel.Description.IContractBehavior
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true)]
public sealed class DeliveryRequirementsAttribute : Attribute, System.ServiceModel.Description.IContractBehavior, System.ServiceModel.Description.IContractBehaviorAttribute
type DeliveryRequirementsAttribute = class
    inherit Attribute
    interface IContractBehavior
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true)>]
type DeliveryRequirementsAttribute = class
    inherit Attribute
    interface IContractBehavior
    interface IContractBehaviorAttribute
Public NotInheritable Class DeliveryRequirementsAttribute
Inherits Attribute
Implements IContractBehavior
Public NotInheritable Class DeliveryRequirementsAttribute
Inherits Attribute
Implements IContractBehavior, IContractBehaviorAttribute
Наследование
DeliveryRequirementsAttribute
Атрибуты
Реализации

Примеры

using System;
using System.ServiceModel;

[ServiceContract]
interface ICalculatorService
{
  [OperationBehavior()]
  int Add(int a, int b);

  [OperationContract]
  int Subtract(int a, int b);
}

[DeliveryRequirementsAttribute(
  QueuedDeliveryRequirements=QueuedDeliveryRequirementsMode.NotAllowed,
  RequireOrderedDelivery=true
)]
class CalculatorService: ICalculatorService
{
  public int Add(int a, int b)
  {
    Console.WriteLine("Add called.");
    return a + b;
  }

  public int Subtract(int a, int b)
  {
    Console.WriteLine("Subtract called.");
    return a - b;
  }

  public int Multiply(int a, int b)
  {
    return a * b;
  }
}
Imports System.ServiceModel

<ServiceContract()> _
Public Interface ICalculatorService

    <OperationBehavior()> _
    Function Add(ByVal a As Integer, ByVal b As Integer) As Integer

    <OperationContract()> _
    Function Subtract(ByVal a As Integer, ByVal b As Integer) As Integer
End Interface

<DeliveryRequirements( _
    QueuedDeliveryRequirements:=QueuedDeliveryRequirementsMode.NotAllowed, _
    RequireOrderedDelivery:=True _
)> _
Class CalculatorService
    Public Function add(ByVal a As Integer, ByVal b As Integer) As Integer
        Console.WriteLine("Add called")
        Return a + b
    End Function

    Public Function Subtract(ByVal a As Integer, ByVal b As Integer) As Integer
        Console.WriteLine("Subtract called.")
        Return a - b
    End Function

    Public Function Multiply(ByVal a As Integer, ByVal b As Integer) As Integer
        Return a * b
    End Function
End Class

Комментарии

Используйте инструкцию DeliveryRequirementsAttribute Windows Communication Foundation (WCF), чтобы убедиться, что привязка предоставляет функции, необходимые для реализации службы или клиента. DeliveryRequirementsAttribute Если атрибут обнаруживается при загрузке описания службы из файла конфигурации приложения или встроенного программным способом в коде, WCF проверяет настроенную привязку и поддерживает все компоненты, заданные атрибутом. Например, службе могут потребоваться привязки для поддержки очереди. Использование DeliveryRequirementsAttribute позволяет WCF убедиться, что выполнены следующие требования:

  • Свойство QueuedDeliveryRequirements задает требования к очереди, которые должны соответствовать привязке.

  • Свойство RequireOrderedDelivery указывает, должна ли привязка поддерживать упорядоченное обмен сообщениями.

  • Свойство указывает, TargetContract к каким типам применяются требования.

Атрибут DeliveryRequirementsAttribute применяется к классу, который может реализовать любое количество интерфейсов контракта службы. DeliveryRequirementsAttribute можно применить ко всем контрактам, которые реализует класс или только к одному из них. Атрибут может применяться к классу более одного раза.

Конструкторы

Имя Описание
DeliveryRequirementsAttribute()

Инициализирует новый экземпляр класса DeliveryRequirementsAttribute.

Свойства

Имя Описание
QueuedDeliveryRequirements

Указывает, должна ли привязка службы поддерживать контракты в очереди.

RequireOrderedDelivery

Указывает, должна ли привязка поддерживать упорядоченные сообщения.

TargetContract

Возвращает или задает тип, к которому он применяется.

TypeId

При реализации в производном классе получает уникальный идентификатор для этого Attribute.

(Унаследовано от Attribute)

Методы

Имя Описание
Equals(Object)

Возвращает значение, указывающее, равен ли этот экземпляр указанному объекту.

(Унаследовано от Attribute)
GetHashCode()

Возвращает хэш-код для этого экземпляра.

(Унаследовано от Attribute)
GetType()

Возвращает Type текущего экземпляра.

(Унаследовано от Object)
IsDefaultAttribute()

При переопределении в производном классе указывает, является ли значение этого экземпляра значением по умолчанию для производного класса.

(Унаследовано от Attribute)
Match(Object)

При переопределении в производном классе возвращает значение, указывающее, равен ли этот экземпляр указанному объекту.

(Унаследовано от Attribute)
MemberwiseClone()

Создает неглубокую копию текущей Object.

(Унаследовано от Object)
ToString()

Возвращает строку, представляющую текущий объект.

(Унаследовано от Object)

Явные реализации интерфейса

Имя Описание
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Сопоставляет набор имен соответствующему набору идентификаторов диспетчеризации.

(Унаследовано от Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Извлекает сведения о типе объекта, который можно использовать для получения сведений о типе для интерфейса.

(Унаследовано от Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Возвращает количество предоставляемых объектом интерфейсов для доступа к сведениям о типе (0 или 1).

(Унаследовано от Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Предоставляет доступ к свойствам и методам, предоставляемым объектом.

(Унаследовано от Attribute)
IContractBehavior.AddBindingParameters(ContractDescription, ServiceEndpoint, BindingParameterCollection)

IContractBehavior.AddBindingParameters(ContractDescription, ServiceEndpoint, BindingParameterCollection) Реализует метод для правильного подключения параметров привязки.

IContractBehavior.ApplyClientBehavior(ContractDescription, ServiceEndpoint, ClientRuntime)

Реализация метода для поддержки IContractBehavior.ApplyClientBehavior(ContractDescription, ServiceEndpoint, ClientRuntime) клиентов.

IContractBehavior.ApplyDispatchBehavior(ContractDescription, ServiceEndpoint, DispatchRuntime)

ApplyDispatchBehavior(ContractDescription, ServiceEndpoint, DispatchRuntime) Реализация метода, который обеспечивает поддержку служб.

IContractBehavior.Validate(ContractDescription, ServiceEndpoint)

IContractBehavior.Validate(ContractDescription, ServiceEndpoint) Реализует метод для включения поддержки проверки.

Применяется к