Share via


BindingElement.CanBuildChannelListener<TChannel>(BindingContext) Metoda

Definice

Vrátí hodnotu, která označuje, zda element vazby může sestavit naslouchací proces pro konkrétní typ kanálu.

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

Parametry typu

TChannel

Typ kanálu, který naslouchací proces přijímá.

Parametry

context
BindingContext

, BindingContext který poskytuje kontext pro element vazby.

Návraty

trueIChannelListener<TChannel>IChannel pokud typ může být vytvořen elementem vazby; v opačném případě false.

Výjimky

context je null.

Příklady

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);

Poznámky

Tuto metodu použijte, pokud chcete před pokusem o sestavení naslouchacího procesu zkontrolovat, jestli je možné pro kanály typu TChannel sestavit context naslouchací proces. Případně můžete vytvořit naslouchací proces kanálu voláním BuildChannelListener a zachytit vygenerovanou výjimku, pokud ho nelze sestavit.

Platí pro