BindingElement.CanBuildChannelFactory<TChannel>(BindingContext) Metoda
Definicja
Zwraca wartość wskazującą, czy element Binding może kompilować fabrykę kanałów dla określonego typu kanału.Returns a value that indicates whether the binding element can build a channel factory for a specific type of channel.
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
Parametry typu
- TChannel
Typ kanału wytwarzanego przez fabrykę kanałów.The type of channel the channel factory produces.
Parametry
- context
- BindingContext
BindingContextZapewnia kontekst dla elementu powiązania.The BindingContext that provides context for the binding element.
Zwraca
true
Jeśli IChannelFactory<TChannel> Typ TChannel
można skompilować za pomocą elementu Binding; w przeciwnym razie, false
.true
if the IChannelFactory<TChannel> of type TChannel
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();
BindingContext context = new BindingContext(binding, parameters);
bool bFlag = element.CanBuildChannelFactory<IRequestChannel>(context);
Uwagi
Użyj tej metody, jeśli chcesz sprawdzić, czy fabryka kanałów dla kanałów typu TChannel
może być kompilacją dla context
dostarczonego przed podjęciem próby skompilowania fabryki.Use this method if you want to check that the channel factory for channels of type TChannel
can be build for the context
provided before attempting to build the factory. Alternatywnie możesz skompilować fabrykę kanałów, wywołując BuildChannelFactory i przechwytując wyjątek wygenerowany, jeśli nie można go skompilować.Alternatively, build the channel factory by calling BuildChannelFactory and catch the exception generated if it cannot be built.