DeliveryRequirementsAttribute.RequireOrderedDelivery 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定绑定是否必须支持已排序消息。
public:
property bool RequireOrderedDelivery { bool get(); void set(bool value); };
public bool RequireOrderedDelivery { get; set; }
member this.RequireOrderedDelivery : bool with get, set
Public Property RequireOrderedDelivery As Boolean
属性值
true
指示 Windows Communication Foundation (WCF) 确认绑定必须支持消息排序;否则为 false
。 默认值为 false
。
示例
下面的代码示例使用 DeliveryRequirementsAttribute 特性指示 WCF 在运行时确认实际绑定是否支持有序消息。
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
注解
将 RequireOrderedDelivery 属性设置为 false
指示 WCF 不执行验证。