ContextBindingElement 类

定义

提供作为绑定元素上下文一部分的保护级别和交换机制以及用于生成通道侦听器和工厂的功能。

public ref class ContextBindingElement : System::ServiceModel::Channels::BindingElement, System::ServiceModel::Channels::IContextBindingElement, System::ServiceModel::Description::IPolicyExportExtension
public class ContextBindingElement : System.ServiceModel.Channels.BindingElement, System.ServiceModel.Channels.IContextBindingElement, System.ServiceModel.Description.IPolicyExportExtension
type ContextBindingElement = class
    inherit BindingElement
    interface IPolicyExportExtension
    interface IContextBindingElement
Public Class ContextBindingElement
Inherits BindingElement
Implements IContextBindingElement, IPolicyExportExtension
继承
ContextBindingElement
实现

注解

ContextBindingElement 允许用户向服务的绑定中添加元素以管理其上下文交换协议。 ContextBindingElement 通常堆叠在可靠性、安全性和传输绑定元素上。 ContextBindingElement 不需要任何配置选项并且可以为 IRequestChannelIRequestSessionChannelIDuplexSessionChannel 创建通道工厂。 它还可以为 IReplyChannelIReplySessionChannelIDuplexSessionChannel 创建通道侦听器。 上下文通道不会更改通道接口 - 基础通道堆栈必须支持请求的通道形状和会话功能。

使用通道侦听器和工厂可以构造用于处理传入和传出消息的通道堆栈部分。

备注

如果基于会话的绑定是使用 创建的,并且与指定 的协定一起使用,则当创建通道时将引发 ,文本如下:"打开通道后无法启用或禁用通道上下文 ContextBindingElement SessionMode = NotAllowed InvalidOperationException 管理。" 必须将 SessionMode 设置为 AllowedRequired,或不使用基于会话的通道。

在创建自定义绑定时,建议你在添加任何可靠性和安全性绑定元素(如果有)之前,将 ContextBindingElement 添加到自定义绑定的 BindingElementCollection。 否则,服务可能会引发 ProtocolException 并显示以下消息:

“上下文通道收到一个消息,该消息包含的上下文与缓存在此通道的当前上下文不匹配。 请确保在对上下文进行了初始设置或者通过将通道属性‘IContextManager.Enabled’设置为 false 禁用了其上下文管理之后,服务没有更改此上下文。”

构造函数

ContextBindingElement()

初始化 ContextBindingElement 类的新实例。

ContextBindingElement(ProtectionLevel)

使用指定的保护级别初始化 ContextBindingElement 类的新实例。

ContextBindingElement(ProtectionLevel, ContextExchangeMechanism)

使用指定的保护级别和交换机制初始化 ContextBindingElement 类的新实例。

ContextBindingElement(ProtectionLevel, ContextExchangeMechanism, Uri)

使用指定的保护级别、上下文交换机制和客户端回调地址初始化 ContextBindingElement 类的新实例。

ContextBindingElement(ProtectionLevel, ContextExchangeMechanism, Uri, Boolean)

使用指定的保护级别、上下文交换机制、客户端回调地址和一个用于指定是否启用上下文管理的值,初始化 ContextBindingElement 类的新实例。

属性

ClientCallbackAddress

获取或设置绑定元素的客户端回调地址。

ContextExchangeMechanism

获取或设置用于传递绑定元素上下文的交换机制。

ContextManagementEnabled

获取或设置一个指定是否已启用上下文管理的值。

ProtectionLevel

获取或设置上下文中绑定元素的安全级别。

方法

BuildChannelFactory<TChannel>(BindingContext)

在客户端上生成通道工厂堆栈,该通道工厂堆栈可为指定上下文创建指定类型的通道。

BuildChannelListener<TChannel>(BindingContext)

在客户端生成通道侦听器堆栈,该通道侦听器堆栈接受针对指定上下文的具有指定类型的通道。

CanBuildChannelFactory<TChannel>(BindingContext)

返回一个值,该值指示当前绑定元素是否可以为指定的通道类型和上下文生成工厂。

CanBuildChannelListener<TChannel>(BindingContext)

返回一个值,该值指示当前绑定是否可以为指定的通道类型和上下文生成侦听器。

Clone()

创建一个从当前对象初始化的新 ContextBindingElement 对象。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
ExportPolicy(MetadataExporter, PolicyConversionContext)

将自定义策略断言写入到绑定元素的上下文中。

GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetProperty<T>(BindingContext)

从通道堆栈的适当层返回具有指定上下文的类型化对象。

GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于