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]