Inject value into injected dependency

前端 未结 2 2033
臣服心动
臣服心动 2020-12-11 04:34

I\'m having something like this:

class Root
{
    public Root(IDependency dep)
    {}
}
class Dependency:IDependency         


        
2条回答
  •  抹茶落季
    2020-12-11 04:35

    With Ninject 3 IParameters (ConstructorArgument is one of them) will now simply be "inherited" to child request when they have ShouldInherit == true (see here).

    The solution for this question can now be as simple as:

    IResolutionRoot.Get(new ConstructorArgument("val", 12, true));
    

    where as the true in the ConstructorArguments constructor sets ShouldInherit to true. Also see here

提交回复
热议问题