Autofac document directory
- Start
- Registering Components
- Control scope and lifecycle
- Structured autofac with modules
- Xml configuration
- Integration with. net
- Deep understanding of autofac
- Guidance
- About
- Vocabulary
Activation event
Use Events at different stages of the component lifecycle.
Autofac exposes three event interfaces that can be called at different stages of the instance.
- Onactivating
- Onactivated
- Onrelease
These events will be subscribed at registration or appended to icomponentregistration.
Builder. registertype <listener> (). onactivated (E => E. instance. startlistening ());
Onactivating
Called before component is created. Here you can
- Redirects an instance to another instance or encapsulates it using a proxy.
- Inject attributes
- Execute other initialization work
Onactivated
It is called once when component is completely created. At this time, you can execute some work at the program level (the work depends on the object being completely created)-This is rare.
Onrelease
Replaces the standard cleaning method of component. The standard cleanup method (not marked as externallyowned) that implements the idisposable interface is called by calling the dispose method. Idisposable is not implemented or is markedExternallyownedIs an empty function-no operation is performed. Onrelease is used to overwrite the default cleanup behavior.