Reputation: 12341
Is there any way to create an instance of ConstructorArgument using lambda expression instead of hardcoded string to define the name of the property?
Something like this:
var validator = Ioc.Kernel.Get<Validators.Security.UserGroupValidator>(new ConstructorArgument( x => x.ValidationDictionary, new ValidationDictionary())
In my case, the ValidationDictionary is not the same in many places and for this reason, I can't use a Provider.
Upvotes: 0
Views: 824
Reputation: 2314
You can use the ToConstructor binding like
http://www.planetgeek.ch/2011/05/28/ninject-constructor-selection-preview/
Bind<UsergroupValidator>().ToConstructor(_ => new Usergroupvalidator(new ValidationDictionary());
Or even let the validation dictionary be injected as defined in the blogpost.
Upvotes: 2