Constructor with multiple arguments with Ninject

后端 未结 2 1006
梦谈多话
梦谈多话 2021-02-05 13:23

I am tring to use Ninject as a IoC container but could not understand how to create an instance of a class that has more than 1 parameter in the constructor. Basically I have a

2条回答
  •  不知归路
    2021-02-05 14:17

    Ninject can inject more than one constructor arguments like:

     Bind().To().InSingletonScope()
                    .WithConstructorArgument("customerName", "Daenerys Targeryan")
                    .WithConstructorArgument("customerAddress", "King's Landing");
    

    It does not change how the binding works.

提交回复
热议问题