Windsor container uses .NET events to notify external subscribers when something interesting happens. You can subscribe to these events and perform some logic as they occur.
ℹ️ Use facilities: Primary usage of these events is for facilities. While there's no limitation for who can subscribe it is considered a good practice to encapsulate this logic within a facility.
The events are defined on IKernelEvents
interface that is exposed by container's Kernel
property. The following events are provided.
Events regarding lifetime of the container.
Raised when current container was added as child container of some other container.
Opposite of the above.
ℹ️ This event is new in Windsor 3
Raised when registration / installation process is completed, that is right before the container exist Install
or Register
(whichever is the outermost).
Events regarding lifetime of a ComponentModel
in the container.
Raised when a new component gets registered with the container.
Raised when a component gets removed from the container.
Raised when a ComponentModel
gets created, but after ComponentModel construction contributors finish their job.
ℹ️ Don't modify the ComponentModel
when handling this event: You should never perform any modification to the ComponentModel
passed to this event. Use ComponentModel construction contributors for that.
Events regarding lifetime of a IHandler
.
Raised when a new handler is registered (it might be in a valid or waiting dependency state).
Raised when a new handler (or group of handlers) is registered (they might be in a valid or waiting dependency state). The difference from HandlerRegistered
is the intent - while the former is concentrated on the newly registered handler, this one is simply a notification that state of the container has changed. Windsor, for example, uses it internally to check if newly registered handlers satisfy missing dependencies of other handlers in WaitingDependency
state.
Events regarding lifetime of a component instance.
Raised right after component was created.
Raised right after component was destroyed.
Raised right after a dependency was resolved. This event is useful to perform some modification on resolved component, similar to OnCreate
method, but globally.
ℹ️ This event is new in Windsor 3
Raised when a collection is being resolved (via IKernel.ResolveAll
method, or indirectly - via collection resolver) and the collection is empty. Implementors would usually log that fact or potentially throw an exception (especially in development).