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.3.0

public event EventHandler<ContainerLockingEventArgs> ContainerLocking


Type: SystemEventHandlerContainerLockingEventArgs

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