开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜