ContainerRegisterInitializer Method (ActionInstanceInitializationData, PredicateInitializerContext)

Simple Injector
Registers an ActionT delegate that runs after the creation of instances for which the supplied predicate returns true. Please note that only instances that are created by the container can be initialized this way.

Namespace:  SimpleInjector
Assembly:  SimpleInjector (in SimpleInjector.dll) Version: 4.0.0

public void RegisterInitializer(
	Action<InstanceInitializationData> instanceInitializer,
	Predicate<InitializerContext> predicate


Type: SystemActionInstanceInitializationData
The delegate that will be called after the instance has been constructed and before it is returned.
Type: SystemPredicateInitializerContext
The predicate that will be used to check whether the given delegate must be applied to a registration or not. The given predicate will be called once for each registration in the container.

ArgumentNullException Thrown when either the instanceInitializer or predicate are null references.
InvalidOperationException Thrown when this container instance is locked and can not be altered.

Note: Initializers are guaranteed to be executed in the order they are registered.

Note: The predicate is not guaranteed to be called once per registration; when a registration's instance is requested for the first time simultaneously over multiple thread, the predicate might be called multiple times. The caller of this method is responsible of supplying a predicate that is thread-safe.

See Also