BindingElement.CanBuildChannelListener<TChannel>(BindingContext) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Type Parameters
- TChannel
The type of channel the listener accepts.
Parameters
- context
- BindingContext
The BindingContext that provides context for the binding element.
Returns
true
if the IChannelListener<TChannel> of type IChannel can be built by the binding element; otherwise, false
.
Exceptions
context
is null
.
Examples
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);
Remarks
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. Alternatively, build the channel listener by calling BuildChannelListener and catch the exception generated if it cannot be built.