【发布时间】:2011-10-24 15:05:11
【问题描述】:
我有以下代码:
kernel.Get<IFoo>(new ConstructorArgument("rule", myRule))
我希望根据 myRule 中的值获得不同的对象。我怎么做? 像这样的伪代码
Bind<IFoo>().To<Foo1>().When(x=>x.Parameters[0].Value.Type=="type1")
Bind<IFoo>().To<Foo2>().When(x=>x.Parameters[0].Value.Type=="type2")
其中 Type 是 myRule 的成员
【问题讨论】:
标签: c# dependency-injection ninject ninject-2