1、InstancePerDependency
对每一个依赖或每一次调用创建一个新的唯一的实例。这也是默认的创建实例的方式。
官方文档解释:Configure the component so that every dependent component or call to Resolve() gets a new, unique instance (default.)
2、InstancePerLifetimeScope
在一个生命周期域中,每一个依赖或调用创建一个单一的共享的实例,且每一个不同的生命周期域,实例是唯一的,不共享的。
官方文档解释: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
在一个做标识的生命周期域中,每一个依赖或调用创建一个单一的共享的实例。打了标识了的生命周期域中的子标识域中可以共享父级域中的实例。若在整个继承层次中没有找到打标识的生命周期域,则会抛出异常:DependencyResolutionException。
官方文档解释: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
在一个生命周期域中所拥有的实例创建的生命周期中,每一个依赖组件或调用Resolve()方法创建一个单一的共享的实例,并且子生命周期域共享父生命周期域中的实例。若在继承层级中没有发现合适的拥有子实例的生命周期域,则抛出异常:DependencyResolutionException。
官方文档解释: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
每一次依赖组件或调用Resolve()方法都会得到一个相同的共享的实例。其实就是单例模式。
官方文档解释:Configure the component so that every dependent component or call to Resolve() gets the same, shared instance.
6、InstancePerHttpRequest
在一次Http请求上下文中,共享一个组件实例。仅适用于asp.net mvc开发。
官方文档解释:Share one instance of the component within the context of a single HTTP request.
相关推荐
AutoFac使用方法总结
多实例中 ResolveByKey 使用InstancePerLifetimeScope 原理:通过中间件 配置作用域 Resolve的时候判断是否开启作用域 如果没有则默认使用Root
EF4+MVC6+AutofacIOC实例自己编写的简单框架,正在完善当中,适合新手学习
Autofac是一款IOC框架,比较于其他的IOC框架,如Spring.NET,Unity,Castle等等所包含的,它很轻量级性能上也是很高的。
自己学习是写的关于ASP.NET MVC3 EF4.1 Autofac的组合实例,使用EF4.1 Codefirst模式,数据库自己会自动生成,代码很简单,分层也很简单,对于初学者可能有点帮助。。。
自己学习时写的关于ASP.NET MVC3 NHibernate Autofac的组合实例,数据库的创建脚本包含在包中,代码很简单,分层也很简单,对于初学者可能有点帮助。。。
用autofac做的一个小实例,可以帮助您再大项目中开发用到,可以提高类实例化的效率,方便项目的管理
关于 ico中比较小巧autofac的一个小demo
var builder = new ContainerBuilder(); builder.RegisterType().As(); Container = builder.Build(); ILog log = Container.Resolve(); log.Id = 1; log.Write();
autofac是比较简单易用的IOC容器。下面我们展示如何通过json配置文件,来进行控制反转。
autofac是一款轻量级的IOC,使用方便。挺不错的,推荐
Autofac.Extras.Quartz, Quartz.Net的Autofac集成 Autofac.Extras.Quartz用于 Quartz.Net的...Autofac.Extras.Quartz 为每个石英作业创建嵌套的litefime作用域。 完成作业执行后释放嵌套作用域。这允许每个作业执
Autofac官方文档PDF版本,可以直接访问官网查看,pdf版本仅为个人学习而下载
MVC Autofac.dll
项目说明: Repository模式的框架数据模型和表字段的一一对应 AutoFac框架依赖注入 jquery datatable完美展示 记得看说明文件和建表哦
最近在学习Autofac,上传几个练习的示例 最近在学习Autofac,上传几个练习的示例
利用 Autofac 注入的 MVC项目 interface架构
AUTOFAC的最简单的使用 三种方法的简单demo
Nuget: Autofac.Extensions.DependencyInjection
AutoFac 插件式开发示例