|
|
Posted on 1/5/2018 9:25:48 PM
|
|
|

1、InstancePerDependency
Create a new unique instance for each dependency or call. This is also the default way to create instances.
Official documentation explains: Configure the component so that every dependent component or call to Resolve() gets a new, unique instance (default.)
2、InstancePerLifetimeScope
In a lifecycle domain, each dependency or call creates a single shared instance, and for each different lifecycle domain, the instance is unique and not shared.
Official documentation explains: 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、InstancePerMatchingLifetimeScope
In an identified lifecycle domain, each dependency or call creates a single shared instance. Instances in the parent domain can be shared in the child identity domain of the identified lifecycle domain. If no identified lifecycle domain is found in the entire inheritance hierarchy, an exception is thrown: DependencyResolutionException.
Official documentation explains: Configure the component so that every dependent component or call to Resolve() within a ILifetimeScope 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 by an instance owned in a lifecycle domain, each dependent component or call to the Resolve() method creates a single shared instance, and the child lifecycle domain shares the instances in the parent lifecycle domain. If no suitable lifecycle domain with child instances is found in the inheritance hierarchy, an exception is thrown: DependencyResolutionException.
Official documentation explains: Configure the component so that every dependent component or call to Resolve() within a ILifetimeScope created 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
Every time you depend on a component or call the Resolve() method, you get the same shared instance. In fact, it is a singleton model.
Official documentation explains: Configure the component so that every dependent component or call to Resolve() gets the same, shared instance.
6、InstancePerHttpRequest
In the context of an Http request, share an instance of a component. Available for asp.net MVC development only. Official documentation explains: Share one instance of the component within the context of a single HTTP request. Official documentation link: http://autofaccn.readthedocs.io/en/latest/lifetime/instance-scope.html
|
Previous:asp.net Get site directory file is emptyNext:GeckoFx Firefox kernel replacement, disable system pop-up warning
|