【发布时间】:2011-09-29 21:06:00
【问题描述】:
例如,我在System.Type 类型的构造函数中注册了具有一个参数的类C1。我有另一个类(C2),注入了类型为 C1 的参数。我想在 C1 构造函数中自动接收typeof(C2)。有没有可能?
示例代码:
public class C1
{
public C1(Type type) {}
// ...
}
public class C2
{
public C2(C1 c1) {}
// ...
}
// Registration
containerBuilder.Register(???);
containerBuilder.Register<C2>();
【问题讨论】:
标签: c# dependency-injection autofac