BindingElement.CanBuildChannelListener<TChannel>(BindingContext) Metoda

Definicja

Zwraca wartość wskazującą, czy element powiązania może skompilować odbiornik dla określonego typu kanału.

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 kanału, który akceptuje odbiornik.

Parametry

context
BindingContext

Element BindingContext , który udostępnia kontekst elementu powiązania.

Zwraca

trueIChannelListener<TChannel> jeśli typ IChannel można skompilować za pomocą elementu powiązania; w przeciwnym razie false.

Wyjątki

context to null.

Przykłady

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

Uwagi

Użyj tej metody, jeśli chcesz sprawdzić, czy odbiornik kanału dla kanałów typu TChannel można skompilować dla podanego context przed podjęciem próby skompilowania odbiornika. Możesz też skompilować odbiornik kanału, wywołując BuildChannelListener i przechwytując wygenerowany wyjątek, jeśli nie można go skompilować.

Dotyczy