BindingElement.CanBuildChannelListener<TChannel>(BindingContext) 方法

定義

傳回值,指出繫結項目是否可以建置特定通道型別的通道接聽程式。

public:
generic <typename TChannel>
 where TChannel : class, System::ServiceModel::Channels::IChannel virtual bool CanBuildChannelListener(System::ServiceModel::Channels::BindingContext ^ context);
public virtual bool CanBuildChannelListener<TChannel> (System.ServiceModel.Channels.BindingContext context) where TChannel : class, System.ServiceModel.Channels.IChannel;
abstract member CanBuildChannelListener : System.ServiceModel.Channels.BindingContext -> bool (requires 'Channel : null and 'Channel :> System.ServiceModel.Channels.IChannel)
override this.CanBuildChannelListener : System.ServiceModel.Channels.BindingContext -> bool (requires 'Channel : null and 'Channel :> System.ServiceModel.Channels.IChannel)
Public Overridable Function CanBuildChannelListener(Of TChannel As {Class, IChannel}) (context As BindingContext) As Boolean

類型參數

TChannel

接聽項接受的通道類型。

參數

context
BindingContext

BindingContext,其提供繫結項目的內容。

傳回

Boolean

如果繫結項目可以建置 true 型別的 IChannelListener<TChannel>,則為 IChannel,否則為 false

例外狀況

contextnull

範例

CustomBinding binding = new CustomBinding();
HttpTransportBindingElement element = new HttpTransportBindingElement();
BindingParameterCollection parameters = new BindingParameterCollection();
Uri baseAddress = new Uri("http://localhost:8000/ChannelApp");
String relAddress = "http://localhost:8000/ChannelApp/service";
BindingContext context = new BindingContext(binding, parameters, baseAddress, relAddress, ListenUriMode.Explicit);

bool bFlag = element.CanBuildChannelListener<IReplyChannel>(context);

備註

如果您要在嘗試建置接聽項之前,先檢查是否可以針對提供的 TChannel 建置 context 型別之通道的通道接聽項,請使用這個方法。 或者,請呼叫 BuildChannelListener 來建置通道接聽程式並攔截產生的例外狀況 (如果無法建置的話)。

適用於