How can I get a model instance inside a DataAnnotationsModelMetadataProvider derived class in MVC2? To be more precise, how can I get the model instance to which a property belongs, inside a GetMetadataForProperty derived method?
Asked
Active
Viewed 200 times
0
-
I want to create a custom ModelMetadataProvider, inheriting from DataAnnotationsModelMetadataProvider. Then I want to override the method GetMetadataForProperty, and inside the new custom definition of the method, get the model instance to which the property being evaluated belongs to. – Guillermo Gutiérrez Mar 26 '13 at 16:22
-
Yes, you're right. Part of DataAnnotations are used for validation. There are two separate DataAnnotations providers, one for Validation, and one for Metadata. I want to create a custom provider for metadata. – Guillermo Gutiérrez Mar 26 '13 at 16:25
-
No, it has nothing to do with validation. I want to set some specific metadata properties acording to the values of some of the model properties, i.e.: ShowForEdit, ShowForDisplay, TemplateHint,... – Guillermo Gutiérrez Mar 26 '13 at 16:34