BindingElement.CanBuildChannelListener<TChannel>(BindingContext) Metoda
Definicja
Zwraca wartość wskazującą, czy element powiązania może kompilować odbiornik dla określonego typu kanału.Returns a value that indicates whether the binding element can build a listener for a specific type of channel.
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.The type of channel the listener accepts.
Parametry
- context
- BindingContext
BindingContextZapewnia kontekst dla elementu powiązania.The BindingContext that provides context for the binding element.
Zwraca
true
Jeśli IChannelListener<TChannel> Typ IChannel można skompilować za pomocą elementu Binding; w przeciwnym razie, false
.true
if the IChannelListener<TChannel> of type IChannel can be built by the binding element; otherwise, false
.
Wyjątki
context
to null
.context
is 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że być kompilacją dla context
dostarczonego przed podjęciem próby skompilowania odbiornika.Use this method if you want to check that the channel listener for channels of type TChannel
can be build for the context
provided before attempting to build the listener. Alternatywnie możesz skompilować odbiornik kanału przez wywołanie BuildChannelListener i przechwycenie wygenerowanego wyjątku, jeśli nie można go skompilować.Alternatively, build the channel listener by calling BuildChannelListener and catch the exception generated if it cannot be built.