ChannelFactory<TChannel> ChannelFactory<TChannel> ChannelFactory<TChannel> ChannelFactory<TChannel> Class

定义

一个创建不同类型通道的工厂,客户端使用这些通道将消息发送到不同配置的服务终结点。A factory that creates channels of different types that are used by clients to send messages to variously configured service endpoints.

generic <typename TChannel>
public ref class ChannelFactory : System::ServiceModel::ChannelFactory, System::ServiceModel::Channels::IChannelFactory<TChannel>
public class ChannelFactory<TChannel> : System.ServiceModel.ChannelFactory, System.ServiceModel.Channels.IChannelFactory<TChannel>
type ChannelFactory<'Channel> = class
    inherit ChannelFactory
    interface IChannelFactory<'Channel>
    interface IChannelFactory
    interface ICommunicationObject
Public Class ChannelFactory(Of TChannel)
Inherits ChannelFactory
Implements IChannelFactory(Of TChannel)

类型参数

TChannel

由通道工厂生成的通道类型。The type of channel produced by the channel factory. 此类型必须为 IOutputChannelIRequestChannelThis type must be either IOutputChannel or IRequestChannel.

继承
派生
实现

示例

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

 BasicHttpBinding binding = new BasicHttpBinding();
 EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");

 ChannelFactory<IRequestChannel> factory =
  new ChannelFactory<IRequestChannel>(binding, address);

 IRequestChannel channel = factory.CreateChannel();
 channel.Open();
 Message request = Message.CreateMessage(MessageVersion.Soap11, "hello");
 Message reply = channel.Request(request);
 Console.Out.WriteLine(reply.Headers.Action);
 reply.Close();
 channel.Close();
 factory.Close();
}	   

下面的代码示例演示如何在工厂创建通道对象前,以编程方式插入客户端行为。The following code example shows how to insert programmatically a client behavior prior to the creation of the channel object by the factory.

public class Client
{
  public static void Main()
  {
    try
    {
      // Picks up configuration from the config file.
      ChannelFactory<ISampleServiceChannel> factory 
        = new ChannelFactory<ISampleServiceChannel>("WSHttpBinding_ISampleService");

      // Add the client side behavior programmatically to all created channels.
      factory.Endpoint.Behaviors.Add(new EndpointBehaviorMessageInspector());

      ISampleServiceChannel wcfClientChannel = factory.CreateChannel();

      // Making calls.
      Console.WriteLine("Enter the greeting to send: ");
      string greeting = Console.ReadLine();
      Console.WriteLine("The service responded: " + wcfClientChannel.SampleMethod(greeting));

      Console.WriteLine("Press ENTER to exit:");
      Console.ReadLine();

      // Done with service. 
      wcfClientChannel.Close();
      Console.WriteLine("Done!");
    }
    catch (TimeoutException timeProblem)
    {
      Console.WriteLine("The service operation timed out. " + timeProblem.Message);
      Console.Read();
    }
    catch (FaultException<SampleFault> fault)
    {
      Console.WriteLine("SampleFault fault occurred: {0}", fault.Detail.FaultMessage);
      Console.Read();
    }
    catch (CommunicationException commProblem)
    {
      Console.WriteLine("There was a communication problem. " + commProblem.Message);
      Console.Read();
    }
  }
Public Class Client
  Public Shared Sub Main()
	Try
	  ' Picks up configuration from the config file.
	  Dim factory As New ChannelFactory(Of ISampleServiceChannel)("WSHttpBinding_ISampleService")

	  ' Add the client side behavior programmatically to all created channels.
	  factory.Endpoint.Behaviors.Add(New EndpointBehaviorMessageInspector())

	  Dim wcfClientChannel As ISampleServiceChannel = factory.CreateChannel()

	  ' Making calls.
	  Console.WriteLine("Enter the greeting to send: ")
            Dim greeting As String = Console.ReadLine()
	  Console.WriteLine("The service responded: " & wcfClientChannel.SampleMethod(greeting))

	  Console.WriteLine("Press ENTER to exit:")
	  Console.ReadLine()

	  ' Done with service. 
	  wcfClientChannel.Close()
	  Console.WriteLine("Done!")
	Catch timeProblem As TimeoutException
	  Console.WriteLine("The service operation timed out. " & timeProblem.Message)
	  Console.Read()
	Catch fault As FaultException(Of SampleFault)
	  Console.WriteLine("SampleFault fault occurred: {0}", fault.Detail.FaultMessage)
	  Console.Read()
	Catch commProblem As CommunicationException
	  Console.WriteLine("There was a communication problem. " & commProblem.Message)
	  Console.Read()
	End Try
  End Sub

注解

使用此泛型类可实现一些更高级的方案,在这些方案中有创建通道工厂(可用于创建多个通道类型)的要求。This generic class enables more advanced scenarios where there is a requirement to create a channel factory that can be used to create more than one type of channel.

以编程方式添加行为时,可以在创建任何通道之前将行为添加到 Behaviors 上相应的 ChannelFactory 属性。When adding behaviors programmatically, the behavior is added to the appropriate Behaviors property on the ChannelFactory prior to the creation of any channel. 有关代码示例,请参见“示例”部分。See the example section for a code sample.

频繁使用此类型的客户端或调用应用程序(例如,中层应用程序也是客户端应用程序)也具有复杂的状态管理需求和性能需求。Frequently client or calling applications (for example, middle-tier applications are client applications, too) using this type also have complex state management needs as well as performance needs. 有关这些方案的详细信息,请参阅中间层客户端应用程序For more information about these scenarios, please see Middle-Tier Client Applications.

构造函数

ChannelFactory<TChannel>() ChannelFactory<TChannel>() ChannelFactory<TChannel>() ChannelFactory<TChannel>()

初始化 ChannelFactory<TChannel> 类的新实例。Initializes a new instance of the ChannelFactory<TChannel> class.

ChannelFactory<TChannel>(Binding) ChannelFactory<TChannel>(Binding) ChannelFactory<TChannel>(Binding) ChannelFactory<TChannel>(Binding)

初始化 ChannelFactory<TChannel> 类的新实例。Initializes a new instance of the ChannelFactory<TChannel> class.

ChannelFactory<TChannel>(Binding, EndpointAddress) ChannelFactory<TChannel>(Binding, EndpointAddress) ChannelFactory<TChannel>(Binding, EndpointAddress) ChannelFactory<TChannel>(Binding, EndpointAddress)

使用指定的绑定和终结点地址初始化 ChannelFactory<TChannel> 类的新实例。Initializes a new instance of the ChannelFactory<TChannel> class with a specified binding and endpoint address.

ChannelFactory<TChannel>(Binding, String) ChannelFactory<TChannel>(Binding, String) ChannelFactory<TChannel>(Binding, String) ChannelFactory<TChannel>(Binding, String)

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

ChannelFactory<TChannel>(ServiceEndpoint) ChannelFactory<TChannel>(ServiceEndpoint) ChannelFactory<TChannel>(ServiceEndpoint) ChannelFactory<TChannel>(ServiceEndpoint)

使用指定的终结点初始化生成通道的 ChannelFactory<TChannel> 类的新实例。Initializes a new instance of the ChannelFactory<TChannel> class that produces channels with a specified endpoint.

ChannelFactory<TChannel>(String) ChannelFactory<TChannel>(String) ChannelFactory<TChannel>(String) ChannelFactory<TChannel>(String)

使用指定的终结点配置名称初始化 ChannelFactory<TChannel> 类的新实例。Initializes a new instance of the ChannelFactory<TChannel> class with a specified endpoint configuration name.

ChannelFactory<TChannel>(String, EndpointAddress) ChannelFactory<TChannel>(String, EndpointAddress) ChannelFactory<TChannel>(String, EndpointAddress) ChannelFactory<TChannel>(String, EndpointAddress)

初始化 ChannelFactory<TChannel> 类的新实例,该类与终结点配置和远程地址的指定名称相关联。Initializes a new instance of the ChannelFactory<TChannel> class associated with a specified name for the endpoint configuration and remote address.

ChannelFactory<TChannel>(Type) ChannelFactory<TChannel>(Type) ChannelFactory<TChannel>(Type) ChannelFactory<TChannel>(Type)

初始化 ChannelFactory<TChannel> 类的新实例。Initializes a new instance of the ChannelFactory<TChannel> class.

方法

Abort() Abort() Abort() Abort()

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

(Inherited from CommunicationObject)
ApplyConfiguration(String) ApplyConfiguration(String) ApplyConfiguration(String) 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.

(Inherited from ChannelFactory)
BeginClose(AsyncCallback, Object) BeginClose(AsyncCallback, Object) BeginClose(AsyncCallback, Object) BeginClose(AsyncCallback, Object)

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

(Inherited from CommunicationObject)
BeginClose(TimeSpan, AsyncCallback, Object) BeginClose(TimeSpan, AsyncCallback, Object) BeginClose(TimeSpan, AsyncCallback, Object) BeginClose(TimeSpan, AsyncCallback, Object)

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

(Inherited from CommunicationObject)
BeginOpen(AsyncCallback, Object) BeginOpen(AsyncCallback, Object) BeginOpen(AsyncCallback, Object) BeginOpen(AsyncCallback, Object)

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

(Inherited from CommunicationObject)
BeginOpen(TimeSpan, AsyncCallback, Object) BeginOpen(TimeSpan, AsyncCallback, Object) BeginOpen(TimeSpan, AsyncCallback, Object) BeginOpen(TimeSpan, AsyncCallback, Object)

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

(Inherited from CommunicationObject)
Close() Close() Close() Close()

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

(Inherited from CommunicationObject)
Close(TimeSpan) Close(TimeSpan) Close(TimeSpan) Close(TimeSpan)

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

(Inherited from CommunicationObject)
CreateChannel() CreateChannel() CreateChannel() CreateChannel()

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

CreateChannel(Binding, EndpointAddress) CreateChannel(Binding, EndpointAddress) CreateChannel(Binding, EndpointAddress) CreateChannel(Binding, EndpointAddress)

创建一个指定类型的通道,该通道用于将消息发送到用指定绑定进行配置的服务终结点。Creates a channel of a specified type that is used to send messages to a service endpoint that is configured with a specified binding.

CreateChannel(Binding, EndpointAddress, Uri) CreateChannel(Binding, EndpointAddress, Uri) CreateChannel(Binding, EndpointAddress, Uri) CreateChannel(Binding, EndpointAddress, Uri)

创建一个指定类型的通道,该通道用于将消息发送到用指定绑定配置的指定传输地址处的服务终结点。Creates a channel of a specified type that is used to send messages to a service endpoint at a specified transport address that is configured with a specified binding.

CreateChannel(EndpointAddress) CreateChannel(EndpointAddress) CreateChannel(EndpointAddress) CreateChannel(EndpointAddress)

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

CreateChannel(EndpointAddress, Uri) CreateChannel(EndpointAddress, Uri) CreateChannel(EndpointAddress, Uri) CreateChannel(EndpointAddress, Uri)

创建一个通道,该通道用于通过指定的传输地址将消息发送到特定终结点地址的服务。Creates a channel that is used to send messages to a service at a specific endpoint address through a specified transport address.

CreateChannel(String) CreateChannel(String) CreateChannel(String) CreateChannel(String)

创建一个通道,该通道用于将消息发送到以指定方式配置其终结点的服务。Creates a channel that is used to send messages to a service whose endpoint is configured in a specified way.

CreateChannelWithActAsToken(SecurityToken) CreateChannelWithActAsToken(SecurityToken) CreateChannelWithActAsToken(SecurityToken) CreateChannelWithActAsToken(SecurityToken)

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

CreateChannelWithActAsToken(SecurityToken, EndpointAddress) CreateChannelWithActAsToken(SecurityToken, EndpointAddress) CreateChannelWithActAsToken(SecurityToken, EndpointAddress) 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.

CreateChannelWithActAsToken(SecurityToken, EndpointAddress, Uri) CreateChannelWithActAsToken(SecurityToken, EndpointAddress, Uri) CreateChannelWithActAsToken(SecurityToken, EndpointAddress, Uri) 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.

CreateChannelWithIssuedToken(SecurityToken) CreateChannelWithIssuedToken(SecurityToken) CreateChannelWithIssuedToken(SecurityToken) CreateChannelWithIssuedToken(SecurityToken)

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

CreateChannelWithIssuedToken(SecurityToken, EndpointAddress) CreateChannelWithIssuedToken(SecurityToken, EndpointAddress) CreateChannelWithIssuedToken(SecurityToken, EndpointAddress) 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.

CreateChannelWithIssuedToken(SecurityToken, EndpointAddress, Uri) CreateChannelWithIssuedToken(SecurityToken, EndpointAddress, Uri) CreateChannelWithIssuedToken(SecurityToken, EndpointAddress, Uri) 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.

CreateChannelWithOnBehalfOfToken(SecurityToken) CreateChannelWithOnBehalfOfToken(SecurityToken) CreateChannelWithOnBehalfOfToken(SecurityToken) CreateChannelWithOnBehalfOfToken(SecurityToken)

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

CreateChannelWithOnBehalfOfToken(SecurityToken, EndpointAddress) CreateChannelWithOnBehalfOfToken(SecurityToken, EndpointAddress) CreateChannelWithOnBehalfOfToken(SecurityToken, EndpointAddress) 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.

CreateChannelWithOnBehalfOfToken(SecurityToken, EndpointAddress, Uri) CreateChannelWithOnBehalfOfToken(SecurityToken, EndpointAddress, Uri) CreateChannelWithOnBehalfOfToken(SecurityToken, EndpointAddress, Uri) 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.

CreateDescription() CreateDescription() CreateDescription() CreateDescription()

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

CreateFactory() CreateFactory() CreateFactory() CreateFactory()

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

(Inherited from ChannelFactory)
EndClose(IAsyncResult) EndClose(IAsyncResult) EndClose(IAsyncResult) EndClose(IAsyncResult)

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

(Inherited from CommunicationObject)
EndOpen(IAsyncResult) EndOpen(IAsyncResult) EndOpen(IAsyncResult) EndOpen(IAsyncResult)

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

(Inherited from CommunicationObject)
EnsureOpened() EnsureOpened() EnsureOpened() EnsureOpened()

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

(Inherited from ChannelFactory)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
Fault() Fault() Fault() Fault()

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

(Inherited from CommunicationObject)
GetCommunicationObjectType() GetCommunicationObjectType() GetCommunicationObjectType() GetCommunicationObjectType()

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

(Inherited from CommunicationObject)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetProperty<T>() GetProperty<T>() GetProperty<T>() GetProperty<T>()

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

(Inherited from ChannelFactory)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
InitializeEndpoint(Binding, EndpointAddress) InitializeEndpoint(Binding, EndpointAddress) InitializeEndpoint(Binding, EndpointAddress) InitializeEndpoint(Binding, EndpointAddress)

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

(Inherited from ChannelFactory)
InitializeEndpoint(ServiceEndpoint) InitializeEndpoint(ServiceEndpoint) InitializeEndpoint(ServiceEndpoint) InitializeEndpoint(ServiceEndpoint)

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

(Inherited from ChannelFactory)
InitializeEndpoint(String, EndpointAddress) InitializeEndpoint(String, EndpointAddress) InitializeEndpoint(String, EndpointAddress) InitializeEndpoint(String, EndpointAddress)

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

(Inherited from ChannelFactory)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
OnAbort() OnAbort() OnAbort() OnAbort()

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

(Inherited from ChannelFactory)
OnBeginClose(TimeSpan, AsyncCallback, Object) OnBeginClose(TimeSpan, AsyncCallback, Object) OnBeginClose(TimeSpan, AsyncCallback, Object) 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.

(Inherited from ChannelFactory)
OnBeginOpen(TimeSpan, AsyncCallback, Object) OnBeginOpen(TimeSpan, AsyncCallback, Object) OnBeginOpen(TimeSpan, AsyncCallback, Object) 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.

(Inherited from ChannelFactory)
OnClose(TimeSpan) OnClose(TimeSpan) OnClose(TimeSpan) OnClose(TimeSpan)

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

(Inherited from ChannelFactory)
OnClosed() OnClosed() OnClosed() OnClosed()

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

(Inherited from CommunicationObject)
OnClosing() OnClosing() OnClosing() OnClosing()

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

(Inherited from CommunicationObject)
OnEndClose(IAsyncResult) OnEndClose(IAsyncResult) OnEndClose(IAsyncResult) OnEndClose(IAsyncResult)

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

(Inherited from ChannelFactory)
OnEndOpen(IAsyncResult) OnEndOpen(IAsyncResult) OnEndOpen(IAsyncResult) OnEndOpen(IAsyncResult)

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

(Inherited from ChannelFactory)
OnFaulted() OnFaulted() OnFaulted() OnFaulted()

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

(Inherited from CommunicationObject)
OnOpen(TimeSpan) OnOpen(TimeSpan) OnOpen(TimeSpan) 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.

(Inherited from ChannelFactory)
OnOpened() OnOpened() OnOpened() OnOpened()

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

(Inherited from ChannelFactory)
OnOpening() OnOpening() OnOpening() OnOpening()

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

(Inherited from ChannelFactory)
Open() Open() Open() Open()

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

(Inherited from CommunicationObject)
Open(TimeSpan) Open(TimeSpan) Open(TimeSpan) Open(TimeSpan)

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

(Inherited from CommunicationObject)
ThrowIfDisposed() ThrowIfDisposed() ThrowIfDisposed() ThrowIfDisposed()

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

(Inherited from CommunicationObject)
ThrowIfDisposedOrImmutable() ThrowIfDisposedOrImmutable() ThrowIfDisposedOrImmutable() ThrowIfDisposedOrImmutable()

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

(Inherited from CommunicationObject)
ThrowIfDisposedOrNotOpen() ThrowIfDisposedOrNotOpen() ThrowIfDisposedOrNotOpen() ThrowIfDisposedOrNotOpen()

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

(Inherited from CommunicationObject)
ToString() ToString() ToString() ToString()

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

(Inherited from Object)

属性

Credentials Credentials Credentials Credentials

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

(Inherited from ChannelFactory)
DefaultCloseTimeout DefaultCloseTimeout DefaultCloseTimeout DefaultCloseTimeout

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

(Inherited from ChannelFactory)
DefaultOpenTimeout DefaultOpenTimeout DefaultOpenTimeout DefaultOpenTimeout

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

(Inherited from ChannelFactory)
Endpoint Endpoint Endpoint Endpoint

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

(Inherited from ChannelFactory)
IsDisposed IsDisposed IsDisposed IsDisposed

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

(Inherited from CommunicationObject)
State State State State

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

(Inherited from CommunicationObject)
ThisLock ThisLock ThisLock ThisLock

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

(Inherited from CommunicationObject)

显式界面实现

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

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

(Inherited from ChannelFactory)

事件

Closed Closed Closed Closed

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

(Inherited from CommunicationObject)
Closing Closing Closing Closing

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

(Inherited from CommunicationObject)
Faulted Faulted Faulted Faulted

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

(Inherited from CommunicationObject)
Opened Opened Opened Opened

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

(Inherited from CommunicationObject)
Opening Opening Opening Opening

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

(Inherited from CommunicationObject)

适用于

线程安全性

此类型是线程安全的。This type is thread safe.