I am using Ninject 1.5 in my MVC project. It works nicely, but since we have Ninject 2, I could upgrade (and additionaly use per request behavior, which didn't work properly in 1.5). Ninject 1.5 had InjectPropertiesWhere
function, which is missing in Ninject 2 (at least it was when I tested it some time ago). Is there something similar?
Example of InjectPropertiesWhere
:
return Bind<IUserService>().To<UserService>()
.InjectPropertiesWhere(p => p.Name.EndsWith("Repository"))
.InjectPropertiesWhere(p => p.Name.EndsWith("Service"))
.InjectPropertiesWhere(p => p.Name == "ApplicationCache")
.InjectPropertiesWhere(p => p.Name == "CurrentPrincipal")
.InjectPropertiesWhere(p => p.Name == "CTEmailSender")
.InjectPropertiesWhere(p => p.Name == "CTSettings");
This is not supported this way by Ninject 2. You have 4 Options:
WithProperty("propertyName", ctx => ctx.Kernel.Get<MyType>())