Reflection, get DataAnnotation attributes from buddy class.

Posted by Feryt on Stack Overflow See other posts from Stack Overflow or by Feryt
Published on 2010-04-09T22:09:22Z Indexed on 2010/04/09 22:13 UTC
Read the original article Hit count: 572

Filed under:
|

Hi. I need to check if property has specific attribute defined in its buddy class:

[MetadataType(typeof(Metadata))]
public sealed partial class Address
{
    private sealed class Metadata
    {
        [Required]
        public string Address1 { get; set; }

        [Required]
        public string Zip { get; set; }
    }
}

How to check what properties has defined Required attribute?

Thank you.

© Stack Overflow or respective owner

Related posts about reflection

Related posts about attributes