惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
IT之家
IT之家
博客园_首页
人人都是产品经理
人人都是产品经理
博客园 - Franky
I
InfoQ
Recent Announcements
Recent Announcements
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
MongoDB | Blog
MongoDB | Blog
雷峰网
雷峰网
博客园 - 聂微东
N
Netflix TechBlog - Medium
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
D
Docker

博客园 - 云龙

win8.1安装出错解决方法之一 vs未能正确加载XX包的解决方法 下载android sdk ubuntu下安装与卸载软件方法 Ubuntu 安装杀毒软件防火墙 Ubuntu 图形处理软件 Ubuntu 下编译Android 源代码 ubuntu 安装配置 JDK7和Android Studio(apt-get方式) ununtu 下安装 Nvidia 显卡驱动 windows 8.1 在硬盘上创建扩展分区 (转)ASP.NET Identity登录原理 - Claims-based认证和OWIN (转)从Membership 到 .NET4.5 之 ASP.NET Identity (转)Asp.Net MVC中身份认证和授权 用JSON数据向已定义列的表格添加数据行 在MVC中动态读取JSON数据创建表格 IIS7.0(虚拟机)发布MVC5程序出现Http403错误的解决方法. 如何避免MVC Model First 设计时添加的DataAnnotation被覆盖掉 移动路由表 cisco路由基于策略的路由选择
Unity4.0配置
云龙 · 2016-06-05 · via 博客园 - 云龙

关于Unity4.0的使用:

一 安装Unity
  在程序包管理器控制台输入命令:Istall-Pckage unity.mvc
安装后会在App_Start中生成UnityConfig.cs 和UnityMvcActivator.cs 两个文件,打开UnityConfig.cs这个文件,修改如下

打开UnityConfig.cs这个文件,修改如下

在Global.asax中增加UnityWebActivator.Start();

Web.comfig:在<configuration></configuration>中加入

  <configSections>
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,Microsoft.Practices.Unity.Configuration"/>
  </configSections>

View Code

然后配置:

  <unity xmlns="http://schemas.microsoft.com/practices/2010/unity" >
    
    <!--版本-->
    <assembly name="LongIBLL"/>
    <assembly name="LongBLL"/>
    <assembly name="LongIDAL"/>
    <assembly name="LongDAL"/>
    
    <!--命名空间-->
    <namespace name="LongIBLL"/>
    <namespace name="LongBLL"/>
    <namespace name ="LongIDAL"/>
    <namespace name ="LongDAL"/>
    <container>
      
      <!--IBLL映射BLL类-->
      <register type="ILongRolesService"                             mapTo="LongRolesService"/>
      <register type="ILongManagersService"                          mapTo="LongManagersService"/>
      <register type="ILongNewsService"                              mapTo="LongNewsService"/>
      <register type="ILongModulesService"                           mapTo="LongModulesService"/>
      <register type="ILongPermissionModulesService"                 mapTo="LongPermissionModulesService"/>
      <register type="ILongPermissionService"                        mapTo="LongPermissionService"/>
      
      <!--IBLL<T>映射BLL类<T> 泛型注入-->
      <register type="IBaseService[]"              mapTo="LongBaseService[]"/>

      <!-- IDAL映射DAL-->
      <register type="ILongRolesRepository"                          mapTo="LongRolesRepository"/>
      <register type="ILongManagersRepository"                       mapTo="LongManagersRepository"/>
      <register type="ILongNewsRepository"                           mapTo="LongNewsRepository"/>
      <register type="ILongModulesRepository"                        mapTo="LongModulesRepository"/>
      <register type="ILongPermissionModulesRepository"              mapTo="LongPermissionModulesRepository"/>
      <register type="ILongPermissionRepository"                     mapTo="LongPermissionRepository"/>

      <!-- IDAL<T>映射DAL<T>泛型注入-->
      <register type="IBaseRepository[]"           mapTo="LongBaseRepository[]"/>
    </container>
  </unity> 

Unity注册配置(web.config)

最后在需要的地方调用