Ninject syntax for “Bind” with multiple arguments

后端 未结 1 1823
闹比i
闹比i 2021-01-03 22:40

How I can use multiple parameters in Ninject syntax like following?

Bind()
.To()
.WithConstructorArgument(\"conn         


        
相关标签:
1条回答
  • 2021-01-03 23:07

    You can chain the calls to WithConstructorArgument:

    Bind<IMyRepository>()
        .To<SqlMyRepository>()
        .WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString)
        .WithConstructorArgument("timeout", 10000);
    
    0 讨论(0)
提交回复
热议问题