語言

BindingElement.CanBuildChannelFactory<TChannel>(BindingContext) 方法

定義

回傳一個值,指示綁定元件是否能為特定類型通道建立通道工廠。

public:
generic <typename TChannel>
 virtual bool CanBuildChannelFactory(System::ServiceModel::Channels::BindingContext ^ context);
public virtual bool CanBuildChannelFactory<TChannel>(System.ServiceModel.Channels.BindingContext context);
abstract member CanBuildChannelFactory : System.ServiceModel.Channels.BindingContext -> bool
override this.CanBuildChannelFactory : System.ServiceModel.Channels.BindingContext -> bool
Public Overridable Function CanBuildChannelFactory(Of TChannel) (context As BindingContext) As Boolean

類型參數

TChannel

頻道工廠生產的頻道類型。

參數

context
BindingContext

BindingContext那就為綁定元素提供了背景。

傳回

true若 型IChannelFactory<TChannel>TChannel態可由綁定元素構成;否則, false。

例外狀況

context 是 null。

範例

CustomBinding binding = new CustomBinding();
HttpTransportBindingElement element = new HttpTransportBindingElement();
BindingParameterCollection parameters = new BindingParameterCollection();
BindingContext context = new BindingContext(binding, parameters);

bool bFlag = element.CanBuildChannelFactory<IRequestChannel>(context);

備註

如果你想在嘗試建置工廠前,先確認能為TChannel所提供類型的context通道建置廠,請使用此方法。 或者,呼叫通道工廠 BuildChannelFactory ,若無法建立,則捕捉產生的例外。

適用於