How to use this functionality in ninject 2.0?
MyType obj = kernel.Get<MyType>(With.Parameters.ConstructorArgument("foo","bar"));
The "With" isn't there :(
[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 ); }
1.4m articles
1.4m replys
5 comments
57.0k users