Unity MVC3依赖注入示例源码2012518

时间:2015-06-08 03:55:58
【文件属性】:
文件名称:Unity MVC3依赖注入示例源码2012518
文件大小:1.16MB
文件格式:ZIP
更新时间:2015-06-08 03:55:58
MVC3 依赖 注入 示例 源码 Unity MVC3依赖注入示例源码 程序介绍: 这个类库可以将Microsoft's Unity IoC简单整合到ASP.NET MVC3中。项目包含一个定制的DependencyResolver,为每一个HTTP请求创建一个子容器并且在请求结束时释放所有注册过IDisposable接口的实例。 来自51ASpXA library that allows simple Integration of Microsoft's Unity IoC container with ASP.NET MVC 3. This project includes a bespoke DependencyResolver that creates a child container per HTTP request and disposes of all registered IDisposable instances at the end of the request. 单步执行代码可以看到每一个web请求ExampleContext的构造函数都被执行一次。上下文环境被两个共享: private static IUnityContainer BuildUnityContainer() { var container = new UnityContainer(); container.RegisterType(); container.RegisterType(); container.RegisterType(new HierarchicalLifetimeManager()); return container; } 当请求结束时,ExampleContext的dispose方法被调用,并且所有相关资源被释放。
【文件预览】:
51aspx_UnityMVC3e89cbd52-5e86-4c23-8baa-4a4190bf9cdc
----.nuget()
--------NuGet.targets(4KB)
--------NuGet.exe(554KB)
--------NuGet.Config(169B)
----Unity.Mvc3()
--------Unity.Mvc3.csproj(4KB)
--------bin()
--------packages.config(167B)
--------PreApplicationStartCode.cs(438B)
--------obj()
--------UnityDependencyResolver.cs(3KB)
--------RequestLifetimeHttpModule.cs(421B)
--------Properties()
----nuget()
--------Build.bat(19B)
--------content()
--------Unity.Mvc3.nuspec(760B)
--------lib()
--------Unity.Mvc3.1.2.nupkg(9KB)
----Unity.Mvc3.suo(48KB)
----.gitignore(94B)
----Unity.Mvc3.sln(2KB)
----Unity.Mvc3.Example()
--------Unity.Mvc3.Example.csproj(7KB)
--------Models()
--------bin()
--------packages.config(212B)
--------Web.config(3KB)
--------obj()
--------Controllers()
--------Unity.Mvc3.README.txt(880B)
--------Global.asax.cs(977B)
--------Global.asax(110B)
--------Views()
--------Content()
--------Properties()
--------Bootstrapper.cs(810B)
----packages()
--------CommonServiceLocator.1.0()
--------Unity.Mvc3.1.2()
--------Unity.2.1.505.0()

网友评论