Ninject syntax for "Bind" with multiple arguments
How I can use multiple parameters in Ninject syntax like following?
开发者_运维问答Bind<IMyRepository>()
.To<SqlMyRepository>()
.WithConstructorArgument("connectionString",
ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString
);
What if more than one parameter need to be passed?
You can chain the calls to WithConstructorArgument
:
Bind<IMyRepository>()
.To<SqlMyRepository>()
.WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString)
.WithConstructorArgument("timeout", 10000);
精彩评论