Unity4.0的使用
最近公司用到了Unity,自己就研究了一下。





/// <summary>Registers the type mappings with the Unity container.</summary>
/// <param name="container">The unity container to configure.</param>
/// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
/// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
public static void RegisterTypes(IUnityContainer container)
{
// NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
container.LoadConfiguration(); // TODO: Register your types here
// container.RegisterType<IProductRepository, ProductRepository>();
}
2.在configSections节点下添加以下内容
<configSections>
<section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,Microsoft.Practices.Unity.Configuration"/>
</configSections>
3.配置unity节点信息
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<assembly name="IBLL"/>
<assembly name="BLL"/>
<containers>
<container>
<register type="IBLL.ITest,IBLL" mapTo="BLL.Test,BLL" />
</container>
</containers>
</unity>
配置完成运行就ok了。
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<containers>
<container>
<register type="IBLL.ITest" mapTo="BLL.Test" />
</container>
</containers>
</unity>
这种情况下会报这种错误

/// <summary>Registers the type mappings with the Unity container.</summary>
/// <param name="container">The unity container to configure.</param>
/// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
/// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
public static void RegisterTypes(IUnityContainer container)
{
// NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
//container.LoadConfiguration(); // TODO: Register your types here
// container.RegisterType<IProductRepository, ProductRepository>();
container.RegisterType<IBLL.ITest,BLL.Test>();
}
以上是个人使用经验分享给大家,上面的内容比较浅显,如果有错误请大家指正
Unity4.0的使用的更多相关文章
- Unity4.0配置
关于Unity4.0的使用: 一 安装Unity 在程序包管理器控制台输入命令:Istall-Pckage unity.mvc安装后会在App_Start中生成UnityConfig.cs 和Unit ...
- Ioc依赖注入:Unity4.0.1 在项目中的应用 (MVC和API)
使用Unity的好处网上有很多,百度一下即可 这里引用了一篇关于面向接口编程的好处的文章作为引申:https://blog.csdn.net/Cyy19970527/article/details/8 ...
- 【英宝通Unity4.0公开课学习 】(五)47讲到75讲
不知不觉今天都已经看了快30讲了,虽然很想快马加鞭地将后面的内容看完,但为了学习的质量,还是挺下来写一篇blog :) 这两天有些昏昏沉沉的,但感觉生活还安排得不错,原因找去找来觉得是没怎么开窗透气. ...
- 【英宝通Unity4.0公开课学习 】(六)76讲到90讲
还是关于Mecanim动画的内容. 这些讲的每讲长度明显比前面的长,而且很多都涉及到脚本编写. 不过我还是2倍速给略览过去了,主要目的就是学个框架嘛 :) 1. Blend Tree 可嵌套. 可理解 ...
- 【英宝通Unity4.0公开课学习 】(四)GUI到物理引擎
今天老妈打电话来说和老爸吵架了... 真的是家家都有本难念的经啊.前后帮她分析了个半小时才帮她解开心结...现在想想老爸还是蛮可怜的,连分享的人都木有 讲的GUI都看睡着了...因为想着可以用NGUI ...
- 【英宝通Unity4.0公开课学习 】(三)脚本使用
清明出去放松了一天. 看了下大姑爷,然后去大姑家吃了个午饭,下午三点左右出去找煤球耍,在他们学校和良乡镇逛了一下.当时感觉离北京好远好远啊... 其实不得不说现在的交通确实很方便,到哪都要不了几天,如 ...
- 【英宝通Unity4.0公开课学习 】(二)场景创建
本讲共四节,貌似讲课老师的速度变快了,2倍速听不清了...调成了1.7倍...老师果然越来越熟练了啊! 而且最开始的萌妹纸也不再出现在视频里了,我当时还想着完全可以换成老师自己提问嘛! 不过有妹纸声音 ...
- 【英宝通Unity4.0公开课学习 】(一)资源管理
经过多次面试后发现自己对Unity3D的框架缺乏一个整体的认识. 而前面由于离职等原因总是忙于修修补补,疲于奔命,感觉相当疲惫. 还好,后来经过调整,开始淡定了起来.得特别感谢一本书哇:<高效人 ...
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(64)-WebApi与Unity注入
系列目录 前言: 有时候我们系统需要开放数据给手机App端或其他移动设备,不得不说Asp.net WebApi是目前首选 本节记录Asp.net MVC WebApi怎么利用Unity注入.系列开头已 ...
随机推荐
- wpf 获取datagrid中模板中控件
//获取name为datagrid中第三列第一行模板的控件 FrameworkElement item = dataGrid.Columns[].GetCellContent(dataGrid.Ite ...
- jquery + header
官网上搜索headers 基本用法(直接用下楼上的代码了) $.ajax({ //请求类型,这里为POST type: 'POST', //你要请求的api的URL url: url , //是否使用 ...
- 数据库大数据处理---复制(SQLServer)
复制? 复制起初并不是用于作为高可用性功能而设计的,实际上复制的概念就像其名称一样,用于复制数据.比如将某个库中的数据“复制”到另一个库,到另一个实例中,由OLTP复制到OLAP环境中,由某数据中心复 ...
- CSS3实现阴阳鱼
直接上代码: <!doctype html> <html> <head> <meta charset="utf-8" /> < ...
- js中join和split的用法
- Coursera-Getting and Cleaning Data-week4-R语言中的正则表达式以及文本处理
博客总目录:http://www.cnblogs.com/weibaar/p/4507801.html Thursday, January 29, 2015 补上第四周笔记,以及本次课程总结. 第四周 ...
- Ulink2 "No Ulink Device found" 解决办法
一.背景 keil使用ULINK2调试的时候,提示 "No Ulink Device found", "error: flash download failed - Ta ...
- 解析XML文档
<html> <body><h1>W3School.com.cn Internal Note</h1><p><b>To:< ...
- python 内置&&递归
lambda 优点: 1:可以简单使用一个脚本来替代我们的函数 2:不用考虑命名的问题 3:简化代码的可读性,不用跳转到def了,省去这样的步骤 内置函数:bif filter:过滤器 map:映射 ...
- HTML文档、javascript脚本的加载与解析
1.onload事件 1.1 onload事件分类 a.文档加载完成事件(包括脚本.图片等资源都加载完),绑定方法:<body onload="doSomething()"& ...