Editar

Compartilhar via


DeliveryRequirementsAttribute Class

Definition

Specifies the feature requirements that bindings must provide to the service or client implementation.

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
Inheritance
DeliveryRequirementsAttribute
Attributes
Implements

Examples

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

Remarks

Use the DeliveryRequirementsAttribute to instruct Windows Communication Foundation (WCF) to confirm that the binding provides the features required by the service or client implementation. If a DeliveryRequirementsAttribute attribute is detected when a service description is loaded from an application configuration file or built programmatically in code, WCF validates the configured binding and supports all the features that the attribute specifies. For example, your service may require the bindings to support queuing. Using DeliveryRequirementsAttribute allows WCF to confirm that the following requirements are met:

The DeliveryRequirementsAttribute attribute is applied to a class, which can implement any number of service contract interfaces. DeliveryRequirementsAttribute can be applied to all the contracts the class implements or to only one of them. The attribute can be applied to a class more than once.

Constructors

DeliveryRequirementsAttribute()

Initializes a new instance of the DeliveryRequirementsAttribute class.

Properties

QueuedDeliveryRequirements

Specifies whether the binding for a service must support queued contracts.

RequireOrderedDelivery

Specifies whether the binding must support ordered messages.

TargetContract

Gets or sets the type to which it applies.

TypeId

When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)

Methods

Equals(Object)

Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode()

Returns the hash code for this instance.

(Inherited from Attribute)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute()

When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object)

When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

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

Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Provides access to properties and methods exposed by an object.

(Inherited from Attribute)
IContractBehavior.AddBindingParameters(ContractDescription, ServiceEndpoint, BindingParameterCollection)

Implements the IContractBehavior.AddBindingParameters(ContractDescription, ServiceEndpoint, BindingParameterCollection) method to attach binding parameters correctly.

IContractBehavior.ApplyClientBehavior(ContractDescription, ServiceEndpoint, ClientRuntime)

Implementation of the IContractBehavior.ApplyClientBehavior(ContractDescription, ServiceEndpoint, ClientRuntime) method for client support.

IContractBehavior.ApplyDispatchBehavior(ContractDescription, ServiceEndpoint, DispatchRuntime)

Implementation of the ApplyDispatchBehavior(ContractDescription, ServiceEndpoint, DispatchRuntime) method that enables service support.

IContractBehavior.Validate(ContractDescription, ServiceEndpoint)

Implements the IContractBehavior.Validate(ContractDescription, ServiceEndpoint) method to enable validation support.

Applies to