问题
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?
回答1:
You can chain the calls to WithConstructorArgument
:
Bind<IMyRepository>()
.To<SqlMyRepository>()
.WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString)
.WithConstructorArgument("timeout", 10000);
来源:https://stackoverflow.com/questions/3686734/ninject-syntax-for-bind-with-multiple-arguments