DuplexChannelFactory<TChannel> 类

定义

提供创建和管理不同类型的双工通道的方式,客户端使用这些通道在服务终结点发送和接收消息。Provides the means to create and manage duplex channels of different types that are used by clients to send and receive messages to and from service endpoints.

generic <typename TChannel>
public ref class DuplexChannelFactory : System::ServiceModel::ChannelFactory<TChannel>
public class DuplexChannelFactory<TChannel> : System.ServiceModel.ChannelFactory<TChannel>
type DuplexChannelFactory<'Channel> = class
    inherit ChannelFactory<'Channel>
Public Class DuplexChannelFactory(Of TChannel)
Inherits ChannelFactory(Of TChannel)

类型参数

TChannel

由通道工厂生成的通道类型。The type of channel produced by the channel factory.

继承
派生

示例

下面的示例演示如何创建通道工厂并用它来创建和管理通道。The following sample shows how to create a channel factory and use it to create and manage channels.

// Construct InstanceContext to handle messages on the callback interface.
// An instance of ChatApp is created and passed to the InstanceContext.
    InstanceContext site = new InstanceContext(new ChatApp());

// Create the participant with the given endpoint configuration.
// Each participant opens a duplex channel to the mesh.
// Participant is an instance of the chat application that has opened a channel to the mesh.

    using (DuplexChannelFactory<IChatChannel> cf =
        new DuplexChannelFactory<IChatChannel>(site,"ChatEndpoint"))
    {
        X509Certificate2 issuer = GetCertificate(
            StoreName.CertificateAuthority,
            StoreLocation.CurrentUser, "CN=" + issuerName,
            X509FindType.FindBySubjectDistinguishedName);
        cf.Credentials.Peer.Certificate =
            GetCertificate(StoreName.My,
            StoreLocation.CurrentUser,
            "CN=" + member,
            X509FindType.FindBySubjectDistinguishedName);
        cf.Credentials.Peer.PeerAuthentication.CertificateValidationMode  =
            X509CertificateValidationMode.Custom;
        cf.Credentials.Peer.PeerAuthentication.CustomCertificateValidator =
            new IssuerBasedValidator();

        using (IChatChannel participant = cf.CreateChannel())
        {
    // Retrieve the PeerNode associated with the participant and register for online/offline events.
    // PeerNode represents a node in the mesh. Mesh is the named collection of connected nodes.
            IOnlineStatus ostat = participant.GetProperty<IOnlineStatus>();
            ostat.Online += new EventHandler(OnOnline);
            ostat.Offline += new EventHandler(OnOffline);

            Console.WriteLine("{0} is ready", member);
            Console.WriteLine("Press <ENTER> to send the chat message.");

    // Announce self to other participants.
            participant.Join(member);
            Console.ReadLine();
            participant.Chat(member, "Hi there - I am chatting");

            Console.WriteLine("Press <ENTER> to terminate this instance of chat.");
            Console.ReadLine();
    // Leave the mesh and close the client.
            participant.Leave(member);
        }
    }

注解

双工通道使得客户端和服务器可以独立地相互通信,这样双方都可以启动对另一方的调用。A duplex channel allows clients and servers to communicate with each other independently so that either can initiate calls to the other. 双工服务可以将消息发送至客户端终结点,从而提供类似事件的行为。A duplex service can send messages to the client endpoint, providing event-like behavior. 当客户端与服务建立会话并为服务提供可用来将消息发送回客户端的通道时,就会发生双工通信。Duplex communication occurs when a client establishes a session with a service and provides the service with a channel on which the service can send messages back to the client. 有多种不同的 CreateChannel 方法可用于创建这些双工通道。The various CreateChannel methods are used to create these duplex channels. 双工消息模式是 Windows Communication Foundation (WCF) 服务可使用的三种消息模式之一。The duplex message pattern is one of three message patterns available to Windows Communication Foundation (WCF) services. 另外两种消息模式是单向模式和请求-答复模式。The other two message patterns are one-way and request-reply.

有关使客户端可以重新连接到服务的双工服务的一般讨论,请参阅 双工服务For a general discussion of duplex services that allow clients to connect back to the service, see Duplex Services. 有关使用通道工厂编写 Windows Communication Foundation (WCF) 客户端应用程序中涉及的步骤的概述和讨论,请参阅 如何:使用 ChannelFactoryFor an outline and discussion of the steps involved in writing a Windows Communication Foundation (WCF) client application using a channel factory, see How to: Use the ChannelFactory. 有关描述如何在实现回调接口以访问使用双工消息模式的服务的客户端类中创建 Windows Communication Foundation (WCF) 客户端的过程,请参阅 如何:使用双工协定访问服务For a procedure describing how to create a Windows Communication Foundation (WCF) client in a client class that implements the callback interface to access a service that uses a duplex messaging pattern, see How to: Access Services with a Duplex Contract.

构造函数

DuplexChannelFactory<TChannel>(InstanceContext)

用指定的实例上下文初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with specified instance context.

DuplexChannelFactory<TChannel>(InstanceContext, Binding)

使用实现回调协定和指定绑定的上下文初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with a context that implements the callback contract and a specified binding.

DuplexChannelFactory<TChannel>(InstanceContext, Binding, EndpointAddress)

使用实现回调协定和指定绑定和终结点地址的对象初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with an object that implements the callback contract and a specified binding and endpoint address.

DuplexChannelFactory<TChannel>(InstanceContext, Binding, String)

使用指定的实例上下文、绑定和远程地址初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with specified instance context, binding, and remote address.

DuplexChannelFactory<TChannel>(InstanceContext, ServiceEndpoint)

使用实现回调协定和指定终结点的对象初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with an object that implements the callback contract and a specified endpoint.

DuplexChannelFactory<TChannel>(InstanceContext, String)

使用实现回调协定以及指定配置的对象初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with an object that implements the callback contract and a specified configuration.

DuplexChannelFactory<TChannel>(InstanceContext, String, EndpointAddress)

使用实现回调协定和指定配置和终结点地址的对象初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with an object that implements the callback contract and a specified configuration and endpoint address.

DuplexChannelFactory<TChannel>(Object)

使用实现回调协定的对象初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with an object that implements the callback contract.

DuplexChannelFactory<TChannel>(Object, Binding)

使用实现回调协定和指定绑定的对象初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with an object that implements the callback contract and a specified binding.

DuplexChannelFactory<TChannel>(Object, Binding, EndpointAddress)

使用实现回调协定和指定绑定和终结点地址的对象初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with an object that implements the callback contract and a specified binding and endpoint address.

DuplexChannelFactory<TChannel>(Object, Binding, String)

使用指定的回调对象、绑定和远程地址初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with specified callback object, binding, and remote address.

DuplexChannelFactory<TChannel>(Object, ServiceEndpoint)

使用实现回调协定和指定终结点的对象初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with an object that implements the callback contract and a specified endpoint.

DuplexChannelFactory<TChannel>(Object, String)

使用实现回调协定以及指定配置的对象初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with an object that implements the callback contract and a specified configuration.

DuplexChannelFactory<TChannel>(Object, String, EndpointAddress)

使用实现回调协定的对象以及指定配置和终结点地址初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with an object that implements the callback contract, and a specified configuration and endpoint address.

DuplexChannelFactory<TChannel>(Type)

使用指定类型的回调实例初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with specified type of callback instance.

DuplexChannelFactory<TChannel>(Type, Binding)

使用指定类型的回调实例和绑定初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with specified type of callback instance and binding.

DuplexChannelFactory<TChannel>(Type, Binding, EndpointAddress)

使用指定类型的回调实例、绑定和远程地址初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with specified type of callback instance, binding, and remote address.

DuplexChannelFactory<TChannel>(Type, Binding, String)

使用指定类型的回调实例、绑定和远程地址初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with the specified type of callback instance, binding, and remote address.

DuplexChannelFactory<TChannel>(Type, ServiceEndpoint)

使用指定类型的回调实例和服务终结点初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with specified type of callback instance and service endpoint.

DuplexChannelFactory<TChannel>(Type, String)

使用指定类型的回调实例和配置初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with specified type of callback instance and configuration.

DuplexChannelFactory<TChannel>(Type, String, EndpointAddress)

使用指定类型的回调实例、配置和远程地址初始化 DuplexChannelFactory<TChannel> 类的新实例。Initializes a new instance of the DuplexChannelFactory<TChannel> class with the specified type of callback instance, configuration, and remote address.

属性

Credentials

获取客户端在通过由工厂产生的通道与服务终结点进行通信时使用的凭据。Gets the credentials used by clients to communicate a service endpoint over the channels produced by the factory.

(继承自 ChannelFactory)
DefaultCloseTimeout

获取为完成关闭操作提供的默认时间间隔。Gets the default interval of time provided for a close operation to complete.

(继承自 ChannelFactory)
DefaultOpenTimeout

获取为完成打开操作提供的默认时间间隔。Gets the default interval of time provided for an open operation to complete.

(继承自 ChannelFactory)
Endpoint

获取由工厂产生的通道所要连接的服务终结点。Gets the service endpoint to which the channels produced by the factory connect.

(继承自 ChannelFactory)
IsDisposed

获取一个值,该值指示通信对象是否已被释放。Gets a value that indicates whether the communication object has been disposed.

(继承自 CommunicationObject)
State

获取指示通信对象当前状态的值。Gets a value that indicates the current state of the communication object.

(继承自 CommunicationObject)
ThisLock

获取在状态转换过程中保护类实例的相互排斥锁。Gets the mutually exclusive lock that protects the class instance during a state transition.

(继承自 CommunicationObject)

方法

Abort()

使通信对象立即从其当前状态转换到正在关闭状态。Causes a communication object to transition immediately from its current state into the closing state.

(继承自 CommunicationObject)
ApplyConfiguration(String)

使用由指定配置文件提供的行为和通道工厂服务终结点中的那些行为来初始化通道工厂。Initializes the channel factory with the behaviors provided by a specified configuration file and with those in the service endpoint of the channel factory.

(继承自 ChannelFactory)
BeginClose(AsyncCallback, Object)

开始一个异步操作以关闭通信对象。Begins an asynchronous operation to close a communication object.

(继承自 CommunicationObject)
BeginClose(TimeSpan, AsyncCallback, Object)

开始一个异步操作以在指定超时内关闭通信对象。Begins an asynchronous operation to close a communication object with a specified timeout.

(继承自 CommunicationObject)
BeginOpen(AsyncCallback, Object)

开始一个异步操作以打开通信对象。Begins an asynchronous operation to open a communication object.

(继承自 CommunicationObject)
BeginOpen(TimeSpan, AsyncCallback, Object)

开始一个异步操作以在指定时间间隔内打开通信对象。Begins an asynchronous operation to open a communication object within a specified interval of time.

(继承自 CommunicationObject)
Close()

使通信对象从其当前状态转换到关闭状态。Causes a communication object to transition from its current state into the closed state.

(继承自 CommunicationObject)
Close(TimeSpan)

使通信对象在指定时间间隔内从当前状态转换到关闭状态。Causes a communication object to transition from its current state into the closed state within a specified interval of time.

(继承自 CommunicationObject)
CreateChannel()

创建到指定终结点地址的指定类型的通道。Creates a channel of a specified type to a specified endpoint address.

(继承自 ChannelFactory<TChannel>)
CreateChannel(EndpointAddress)

创建用于将消息发送到特定终结点地址的服务的通道。Creates a channel that is used to send messages to a service at a specific endpoint address.

(继承自 ChannelFactory<TChannel>)
CreateChannel(EndpointAddress, Uri)

在服务和客户端上的回调实例之间创建双工通道。Creates a duplex channel between a service and a callback instance on the client.

CreateChannel(InstanceContext)

在服务和客户端上的回调实例之间创建双工通道。Creates a duplex channel between a service and a callback instance on the client.

CreateChannel(InstanceContext, Binding, EndpointAddress)

在服务和客户端上的回调实例之间创建双工通道。Creates a duplex channel between a service and a callback instance on the client.

CreateChannel(InstanceContext, Binding, EndpointAddress, Uri)

在服务和客户端上的回调实例之间创建双工通道。Creates a duplex channel between a service and a callback instance on the client.

CreateChannel(InstanceContext, EndpointAddress)

在服务和客户端上的回调实例之间创建双工通道。Creates a duplex channel between a service and a callback instance on the client.

CreateChannel(InstanceContext, EndpointAddress, Uri)

在服务和客户端上的回调实例之间创建双工通道。Creates a duplex channel between a service and a callback instance on the client.

CreateChannel(InstanceContext, String)

在服务和客户端上的回调实例之间创建双工通道。Creates a duplex channel between a service and a callback instance on the client.

CreateChannel(Object, Binding, EndpointAddress)

在服务和客户端上的回调实例之间创建双工通道。Creates a duplex channel between a service and a callback instance on the client.

CreateChannel(Object, Binding, EndpointAddress, Uri)

在服务和客户端上的回调实例之间创建双工通道。Creates a duplex channel between a service and a callback instance on the client.

CreateChannel(Object, String)

在服务和客户端上的回调实例之间创建双工通道。Creates a duplex channel between a service and a callback instance on the client.

CreateChannelWithActAsToken(SecurityToken)

创建用于将消息发送到有作为安全令牌行为的服务的通道。Creates a channel that is used to send messages to a service with an act as security token.

(继承自 ChannelFactory<TChannel>)
CreateChannelWithActAsToken(SecurityToken, EndpointAddress)

创建一个通道,该通道用于将消息发送到位于特定终结点地址的、具有一个作为安全令牌的行为的服务。Creates a channel that is used to send messages to a service with an act as security token at a specific endpoint address.

(继承自 ChannelFactory<TChannel>)
CreateChannelWithActAsToken(SecurityToken, EndpointAddress, Uri)

创建一个通道,该通道用于通过指定的传输地址将消息发送到位于特定终结点地址的、具有一个作为安全令牌的行为的服务。Creates a channel that is used to send messages to a service with an act as security token at a specific endpoint address through a specified transport address.

(继承自 ChannelFactory<TChannel>)
CreateChannelWithIssuedToken(SecurityToken)

创建用于将消息发送到含有已发布安全令牌的服务的通道。Creates a channel that is used to send messages to a service with an issued security token.

(继承自 ChannelFactory<TChannel>)
CreateChannelWithIssuedToken(SecurityToken, EndpointAddress)

创建一个通道,该通道用于将消息发送到位于特定终结点地址的、具有一个已发布的安全令牌的服务。Creates a channel that is used to send messages to a service with an issued security token at a specific endpoint address.

(继承自 ChannelFactory<TChannel>)
CreateChannelWithIssuedToken(SecurityToken, EndpointAddress, Uri)

创建一个通道,该通道用于通过指定的传输地址将消息发送到位于特定终结点地址的、具有一个已发布的安全令牌的服务。Creates a channel that is used to send messages to a service with an issued security token at a specific endpoint address through a specified transport address.

(继承自 ChannelFactory<TChannel>)
CreateChannelWithOnBehalfOfToken(SecurityToken)

创建用于将消息发送到有代表安全令牌行为的服务的通道。Creates a channel that is used to send messages to a service with an on behalf of security token.

(继承自 ChannelFactory<TChannel>)
CreateChannelWithOnBehalfOfToken(SecurityToken, EndpointAddress)

创建用于将消息发送到特定终结点地址的服务的通道,该服务有安全令牌。Creates a channel that is used to send messages to a service with an on behalf of security token at a specific endpoint address.

(继承自 ChannelFactory<TChannel>)
CreateChannelWithOnBehalfOfToken(SecurityToken, EndpointAddress, Uri)

创建一个通道,该通道用于通过指定的传输地址将消息发送到位于特定终结点地址的、代表安全令牌的服务。Creates a channel that is used to send messages to a service with an on behalf of security token at a specific endpoint address through a specified transport address.

(继承自 ChannelFactory<TChannel>)
CreateDescription()

创建服务终结点的说明。Creates a description of the service endpoint.

(继承自 ChannelFactory<TChannel>)
CreateFactory()

为工厂的当前终结点生成通道工厂。Builds the channel factory for the current endpoint of the factory.

(继承自 ChannelFactory)
EndClose(IAsyncResult)

完成一个异步操作以关闭通信对象。Completes an asynchronous operation to close a communication object.

(继承自 CommunicationObject)
EndOpen(IAsyncResult)

完成一个异步操作以打开通信对象。Completes an asynchronous operation to open a communication object.

(继承自 CommunicationObject)
EnsureOpened()

打开尚未打开的当前通道工厂。Opens the current channel factory if it is not yet opened.

(继承自 ChannelFactory)
Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
Fault()

使通信对象从其当前状态转换到出错状态。Causes a communication object to transition from its current state into the faulted state.

(继承自 CommunicationObject)
GetCommunicationObjectType()

获取通信对象的类型。Gets the type of communication object.

(继承自 CommunicationObject)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

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

从通道堆栈的适当层返回所请求的类型化对象,如果不存在,则返回 nullReturns the typed object requested, if present, from the appropriate layer in the channel stack, or null if not present.

(继承自 ChannelFactory)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeEndpoint(Binding, EndpointAddress)

使用指定的绑定和地址初始化通道工厂的服务终结点。Initializes the service endpoint of the channel factory with a specified binding and address.

(继承自 ChannelFactory)
InitializeEndpoint(ServiceEndpoint)

使用指定的终结点初始化通道工厂的服务终结点。Initializes the service endpoint of the channel factory with a specified endpoint.

(继承自 ChannelFactory)
InitializeEndpoint(String, EndpointAddress)

使用指定的地址和配置初始化通道工厂的服务终结点。Initializes the service endpoint of the channel factory with a specified address and configuration.

(继承自 ChannelFactory)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
OnAbort()

终止当前通道工厂的内部通道工厂。Terminates the inner channel factory of the current channel factory.

(继承自 ChannelFactory)
OnBeginClose(TimeSpan, AsyncCallback, Object)

对当前通道工厂(具有关联的状态对象)的内部通道工厂,开始一个异步关闭操作。Begins an asynchronous close operation on the inner channel factory of the current channel factory that has a state object associated with it.

(继承自 ChannelFactory)
OnBeginOpen(TimeSpan, AsyncCallback, Object)

对当前通道工厂(具有关联的状态对象)的内部通道工厂,开始一个异步打开操作。Begins an asynchronous open operation on the inner channel factory of the current channel factory that has a state object associated with it.

(继承自 ChannelFactory)
OnClose(TimeSpan)

使用完成操作的指定超时对内部通道工厂调用 close。Calls close on the inner channel factory with a specified time-out for the completion of the operation.

(继承自 ChannelFactory)
OnClosed()

在通信对象转换到正在关闭状态的过程中被调用。Invoked during the transition of a communication object into the closing state.

(继承自 CommunicationObject)
OnClosing()

在通信对象转换到正在关闭状态的过程中被调用。Invoked during the transition of a communication object into the closing state.

(继承自 CommunicationObject)
OnEndClose(IAsyncResult)

对当前通道工厂的内部通道工厂,完成一个异步关闭操作。Completes an asynchronous close operation on the inner channel factory of the current channel factory.

(继承自 ChannelFactory)
OnEndOpen(IAsyncResult)

对当前通道工厂的内部通道工厂,完成一个异步打开操作。Completes an asynchronous open operation on the inner channel factory of the current channel factory.

(继承自 ChannelFactory)
OnFaulted()

在调用了同步错误操作,从而引起通信对象转换为出错状态的情况下,该方法插入对通信对象的处理。Inserts processing on a communication object after it transitions to the faulted state due to the invocation of a synchronous fault operation.

(继承自 CommunicationObject)
OnOpen(TimeSpan)

使用完成操作的指定超时对当前通道工厂的内部通道工厂调用 open。Calls open on the inner channel factory of the current channel factory with a specified time-out for the completion of the operation.

(继承自 ChannelFactory)
OnOpened()

为通道工厂初始化 ClientCredentials 对象的一个只读副本。Initializes a read-only copy of the ClientCredentials object for the channel factory.

(继承自 ChannelFactory)
OnOpening()

为当前的通道生成内部通道工厂。Builds the inner channel factory for the current channel.

(继承自 ChannelFactory)
Open()

使通信对象从已创建状态转换到已打开状态。Causes a communication object to transition from the created state into the opened state.

(继承自 CommunicationObject)
Open(TimeSpan)

使通信对象在指定时间间隔内从已创建状态转换到已打开状态。Causes a communication object to transition from the created state into the opened state within a specified interval of time.

(继承自 CommunicationObject)
ThrowIfDisposed()

如果通信对象已释放,则引发异常。Throws an exception if the communication object is disposed.

(继承自 CommunicationObject)
ThrowIfDisposedOrImmutable()

如果通信对象的 State 属性未设置为 Created 状态,则引发异常。Throws an exception if the communication object the State property is not set to the Created state.

(继承自 CommunicationObject)
ThrowIfDisposedOrNotOpen()

如果通信对象未处于 Opened 状态,则引发异常。Throws an exception if the communication object is not in the Opened state.

(继承自 CommunicationObject)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

事件

Closed

当通信对象转换到已关闭状态时发生。Occurs when a communication object transitions into the closed state.

(继承自 CommunicationObject)
Closing

当通信对象转换到正在关闭状态时发生。Occurs when a communication object transitions into the closing state.

(继承自 CommunicationObject)
Faulted

在通信对象转换到出错状态时发生。Occurs when a communication object transitions into the faulted state.

(继承自 CommunicationObject)
Opened

当通信对象转换到已打开状态时发生。Occurs when a communication object transitions into the opened state.

(继承自 CommunicationObject)
Opening

当通信对象转换到正在打开状态时发生。Occurs when a communication object transitions into the opening state.

(继承自 CommunicationObject)

显式接口实现

IDisposable.Dispose()

关闭当前的通道工厂。Closes the current channel factory.

(继承自 ChannelFactory)

适用于