如何在Ninject语法中使用多个参数,如下所示?
Bind<IMyRepository>()
.To<SqlMyRepository>()
.WithConstructorArgument("connectionString",
ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString
);
如果需要传递多个参数怎么办?
答案 0 :(得分:60)
您可以将来电链接到WithConstructorArgument
:
Bind<IMyRepository>()
.To<SqlMyRepository>()
.WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString)
.WithConstructorArgument("timeout", 10000);