Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 784
rem Avatar asked Sep 10 '10 17:09

rem


1 Answers

You can chain the calls to WithConstructorArgument:

Bind<IMyRepository>()
    .To<SqlMyRepository>()
    .WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString)
    .WithConstructorArgument("timeout", 10000);
like image 190
Martin Owen Avatar answered Oct 19 '22 22:10

Martin Owen