This project is read-only.

Creating a Custom Validation Attribute injecting dependencies

Topics: Core, Customizing Orchard
Jul 17, 2014 at 12:43 PM

I am trying to create some custom validation attributes in my Models and I need this attributes to have access to some classes (mainly repositories) which are registered at Module level using Autofac.

I have tried to simply define the property as public but it seems that Autofac ignores it. Of course being a validation attribute I cannot define a constructor so I have to rely on Property injection.

I have tried to follow some of the examples in the ILogger module, as explained in a SO question I found but that did not help.

Does anyone have any idea what is needed to get Autofac to create the Attributes and inject the right property?