ContainerOptionsContainerLocking Event

Simple Injector
Occurs just before the container is about to be locked, giving the developer a last change to interact and change the unlocked container before it is sealed for further modifications. Locking typically occurs by a call to Container.GetInstance, Container.Verify, or any other method that causes the construction and resolution of registered instances.

Namespace:  SimpleInjector
Assembly:  SimpleInjector (in SimpleInjector.dll) Version: 5.0.0
Syntax

public event EventHandler<ContainerLockingEventArgs> ContainerLocking

Value

Type: SystemEventHandlerContainerLockingEventArgs
Remarks

The ContainerLocking event is called exactly once by the container, allowing a developer to register types, hook unregistered type resolution events that need to be applied last, or see who is responsible for locking the container.

A registered event handler delegate is allowed to make a call that locks the container, e.g. calling Container.GetInstance; this will not cause any new ContainerLocking event to be raised. Doing so, however, is not advised, as that might cause any following executed handlers to break, in case they require an unlocked container.

See Also

Reference