Autofac document: Events

Source: Internet
Author: User
Autofac document directory
  1. Start
  2. Registering Components
  3. Control scope and lifecycle
  4. Structured autofac with modules
  5. Xml configuration
  6. Integration with. net
  7. Deep understanding of autofac
  8. Guidance
  9. About
  10. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.