Attributes are created by the .NET Framework. So you can't do Constructor injection. The only two ways to inject into Attributes is to do PropertyInjection or ServiceLocation.
PropertyInjection can be done like this:
- Add a
IPlanningStrategy
that does the scanning with reflection for your attribute (orActionMethodSelectorAttribute
). Return immediatly if not a controller. - Foreach method that has this attribute add a
IDirective
that contains a reference to theMethodInfo
- Add A
IActivationStrategy
that injects the attribute usingkernel.Inject(attribute)
.
Best you have a look at the PropertyInjection
implementation of Ninject it works exactly like this. It just needs some changes to do what you want.