依赖注入的延迟解决 [英] Lazy resolution of dependency injection

查看:77
本文介绍了依赖注入的延迟解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有.net类
我正在使用unity作为IOC来解决我们的依赖关系。
它尝试在开始时加载所有依赖项。
Unity中是否有一种方法(设置)可以在运行时加载依赖项?

解决方案

还有更好的方法解决方案-对Lazy T的本地支持。和IEnumerable< Lazy< T>在Unity 2.0中在此处中进行检查。。 p>

I have .net classes I am using unity as IOC for resolving our dependencies. It tries to load all the dependencies at the beginning. Is there a way (setting) in Unity which allows to load a dependency at runtime?

解决方案

There's even better solution - native support for Lazy<T> and IEnumerable<Lazy<T>> in the Unity 2.0. Check it out here.

这篇关于依赖注入的延迟解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆