Conditionally registers that registration will be used every time a TService requested and where the supplied predicate returns true. The predicate will only be evaluated a finite number of times; the predicate is unsuited for making decisions based on runtime conditions.
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 4.6.0
public void RegisterConditional<TService>( Registration registration, Predicate<PredicateContext> predicate )
Public Sub RegisterConditional(Of TService) ( registration As Registration, predicate As Predicate(Of PredicateContext) )
- Type: SimpleInjectorRegistration
The Registration instance to register.
- Type: SystemPredicatePredicateContext
The predicate that determines whether the registration can be applied for the requested service type. This predicate can be used to build a fallback mechanism where multiple registrations for the same service type are made. Note that the predicate will be called a finite number of times and its result will be cached for the lifetime of the container. It can't be used for selecting a type based on runtime conditions.
- The base type or interface to register. This can be an open-generic type.
|ArgumentNullException||Thrown when one of the arguments is a null reference (Nothing in VB).|
|InvalidOperationException||Thrown when this container instance is locked and can not be altered.|