How to create an instance using autofac [go to]

Source: Internet
Author: User

1. instanceperdependency

Create a unique instance for each dependency or each call. This is also the default instance creation method.

Official documentation explanation: configure the component so that every dependent component or call to resolve () gets a new, unique instance (default .)


2. instanceperlifetimesloud

In a lifecycle domain, each dependency or call creates a single shared instance, and each different lifecycle domain, the instance is unique and not shared.

Official documentation explanation: configure the component so that every dependent component or call to resolve () within a single ilifetimescope gets the same, shared instance. dependent components in Different lifetime scopes will get different instances.


3. instancepermatchinglifetimes.pdf

In a lifecycle domain that is identified, each dependency or call creates a single shared instance. Instances in the parent domain can be shared in the sub-ID domain in the lifecycle domain identified by the user. If the identified lifecycle field is not found in the entire inheritance level, a dependencyresolutionexception is thrown.

Official documentation explanation: configure the component so that every dependent component or call to resolve () within a ilifetimes1_tagged with any of the provided tags value gets the same, shared instance. dependent components in lifetime scopes that are children of the tagged scope will share the parent's instance. if no appropriately tagged scope can be found in the hierarchy an dependencyresolutionexception is thrown.


4. instanceperowned

In the lifecycle of an instance created in a lifecycle domain, each dependent component or the resolve () method is called to create a single shared instance, the sub-lifecycle domain shares instances in the parent lifecycle domain. If no appropriate lifecycle domain with sub-instances is found at the inheritance level, the dependencyresolutionexception is thrown.

Official documentation explanation: configure the component so that every dependent component or call to resolve () within a ilifetimessponcreated by an owned instance gets the same, shared instance. dependent components in lifetime scopes that are children of the owned instance scope will share the parent's instance. if no appropriate owned instance scope can be found in the hierarchy an dependencyresolutionexception is thrown.


5. singleinstance

Each time the dependent component or the resolve () method is called, an identical shared instance is obtained. This is actually the singleton mode.

Official documentation explanation: configure the component so that every dependent component or call to resolve () gets the same, shared instance.


6. instanceperhttprequest

Share a component instance in an HTTP request context. Only applicable to Asp.net MVC development.

Official Document explanation: share one instance of the component within the context of a single HTTP request.

 

 

 

 

Reprinted from: http://blog.csdn.net/dhx20022889/article/details/9061483

How to create an instance using autofac [go to]

Related Article

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.