With.Parameters.ConstructorArgument with ninject 2.0

and*_*cci 35 c# ninject

如何在ninject 2.0中使用此功能?

MyType obj = kernel.Get<MyType>(With.Parameters.ConstructorArgument("foo","bar"));
Run Code Online (Sandbox Code Playgroud)

"With"不存在:(

Ian*_*vis 66

   [Fact]
   public void CtorArgTestResolveAtGet()
   {
       IKernel kernel = new StandardKernel();
       kernel.Bind<IWarrior>().To<Samurai>();
       var warrior = kernel
           .Get<IWarrior>( new ConstructorArgument( "weapon", new Sword() ) );
       Assert.IsType<Sword>( warrior.Weapon );
   }

   [Fact]
   public void CtorArgTestResolveAtBind()
   {
       IKernel kernel = new StandardKernel();
       kernel.Bind<IWarrior>().To<Samurai>()
           .WithConstructorArgument("weapon", new Sword() );
       var warrior = kernel.Get<IWarrior>();
       Assert.IsType<Sword>( warrior.Weapon );
   }
Run Code Online (Sandbox Code Playgroud)