To select a specific constructor, you can use this syntax:

//Create container.
var injector = new MugenInjector();

//Take empty constructor
injector.Bind<ConstructorTest>().ToSelf().TakeConstructor();

//Take constructor with string parameter
injector.Bind<ConstructorTest>().ToSelf().TakeConstructor<string>();

//Take empty constructor
injector.Bind<ConstructorTest>().To(context => new ConstructorTest());

//Take constructor with string parameter
injector.Bind<ConstructorTest>().To(context => new ConstructorTest(context.Resolve<string>()));

Last edited Apr 5, 2012 at 2:53 PM by VVS0205, version 1

Comments

No comments yet.