在 Autofac 2.1 的 beta 版本中,支持自动解析 Lazy,如 Nicholas Blumhardt 的 使用 Autofac 闲逛 博客文章.
In beta builds of Autofac 2.1 there was support for automatic resolution of Lazy<T> as described in Nicholas Blumhardt's Lazing Around with Autofac blog post.
代码似乎仍然在谷歌代码的源代码中,但我在我看过的任何 .NET 4.0 二进制文件中都找不到 LazyDependencyModule.是不是搬到别的地方去了?
The code still seems to be in the source on Google Code, but I can't find LazyDependencyModule in any of the .NET 4.0 binaries I've looked at. Has it moved somewhere else?
如何在最新的 Autofac 版本中使用 Autofac 的自动 Lazy 分辨率?
How do I use Autofac's automatic Lazy<T> resolution with the latest Autofac builds?
推荐答案您无需在生产 Autofac 2 版本中自己注册 LazyDependencyModule.它是默认容器的一部分,因此只需注册 T 和 Lazy 将被提供.
You don't need to register LazyDependencyModule yourself in the production Autofac 2 builds. It is a part of the default container, so just register T and Lazy<T> will be provided.
确保您没有意外使用 .NET 3.5 二进制文件:)
Make sure you're not accidentally using a .NET 3.5 binary, too :)
尼克
更多推荐
Lazy<T> 怎么了?Autofac 支持吗?
发布评论