BindingElement.CanBuildChannelFactory<TChannel>(BindingContext) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回值,指出繫結項目是否可以建置 (Build) 特定通道類型的通道處理站。
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 來建置通道處理站並攔截產生的例外狀況 (如果無法建置的話)。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應