autofac 创建实例方法总结
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 创建实例方法总结的更多相关文章
- Autofac创建实例的方法总结 【转】
Autofac创建实例的方法总结 1.InstancePerDependency 对每一个依赖或每一次调用创建一个新的唯一的实例.这也是默认的创建实例的方式. 官方文档解释:Configure t ...
- Java的几种创建实例方法的性能对比
近来打算自己封装一个比较方便读写的Office Excel 工具类,前面已经写了一些,比较粗糙本就计划重构一下,刚好公司的电商APP后台原有的导出Excel实现出现了可怕的性能问题,600行的数据生成 ...
- [转] Autofac创建实例的方法总结
1.InstancePerDependency 对每一个依赖或每一次调用创建一个新的唯一的实例.这也是默认的创建实例的方式. 官方文档解释:Configure the component so tha ...
- Autofac创建实例的方法总结
1.InstancePerDependency 对每一个依赖或每一次调用创建一个新的唯一的实例.这也是默认的创建实例的方式. 2.InstancePerLifetimeScope 在一个生命周期域中, ...
- Autofac创建实例的方法总结[转]
1.InstancePerDependency 对每一个依赖或每一次调用创建一个新的唯一的实例.这也是默认的创建实例的方式. 官方文档解释:Configure the component so tha ...
- Java的几种创建实例方法的性能对比(二)
上一篇里对几种书写方式进行了简单的测试,得出了一些初步的结论.这次简单了解Lambda原理后,对测试做了一些调整,发现得到不一样的结果,而这个调整,明显更契合实际开发的场景. 暂时还没有亲自去验证,主 ...
- Autofac 依赖注入框架 使用
简介 Autofac是一款IOC框架,比较于其他的IOC框架,如Spring.NET,Unity,Castle等等所包含的,它很轻量级性能上非常高. 官方网站http://autofac.org/ 源 ...
- autofac 注入生命周期
创建实例方法 1.InstancePerDependency 对每一个依赖或每一次调用创建一个新的唯一的实例.这也是默认的创建实例的方式. 官方文档解释:Configure the component ...
- autoface
Autofac 依赖注入框架 使用 2015-08-02 10:20 by jiangys, 36262 阅读, 4 评论, 收藏, 编辑 简介 Autofac是一款IOC框架,比较于其他的IOC框架 ...
随机推荐
- log4j - 输出格式控制, PatternLayout参数含义以及详细配置
转载自:https://blog.csdn.net/reserved_person/article/details/52849505 做项目被log4j的输出格式化参数搞烦了,索性把API的相关部分大 ...
- 1-OSI七层模型详解
1.网络协议种类 市面上存在4,5,7层协议. 1.1 国际标准化组织ISO发布的OSI 7层协议模型(即OSI开放式互联参考模型),是概念性模型. 1.2 TCP/IP是一种实践类的模型,已成为行业 ...
- Shell基础总结
一.用户登陆进入系统后的系统环境变量 $HOME 使用者自己的目录 $PATH 执行命令时所搜寻的目录 $TZ 时区 $MAILCHECK 每隔多少秒检查是否有新的信件 $PS1 在命令列时的提示号 ...
- Node.js的单元测试框架初体验
Mocha是一个功能丰富的JavaScript测试框架,运行在node.js平台和浏览器端,使异步测试变得简单和有趣.Mocha测试是串行的,允许灵活和准确的报告,同时将未捕获的异常映射到相应的测试用 ...
- events.py 知识点记录
1.__all__ __all__是一个字符串list,其他模块中使用from xxx import *的时候只能导入__all__列表里的内容 2.sys.version_info 获取版本号 im ...
- zTree:一个依靠 jQuery 实现的多功能 “树插件”
官方网站: http://www.treejs.cn/v3/main.php#_zTreeInfo 使用方式: 步骤1.文件准备 将需要使用的 zTree v3.x 相关的 js.css.img 文件 ...
- selenium中,8种 find element 方法
-*- coding;utf-8 -*- from selenium import webdriver dr = webdriver.Chrome() dr.get("https://www ...
- zabbix批量监控urls的状态码
.添加url监控脚本 [root@node1 usr]# vim /usr/local/zabbix_agents_3.2.0/scripts/web_site_code_status.sh #!/b ...
- elasticsearch自动按天创建索引脚本
elasticsearch保存在一个索引中数据量太大无法查询,现在需要将索引按照天来建,查询的时候关联查询即可 有时候es集群创建了很多索引,删不掉,如果是测试环境或者初始化es集群(清空所有数据), ...
- hadoop生态系统主要架构图汇总
1 hadoop1.0时期架构 2 hadoop2.0时期架构 3 hdfs架构 [Active Namenode]:主 Master(只有一个),管理 HDFS 的名称空间,管理数据块映射信息:配置 ...