lundi 3 juillet 2017

Get all properties from an object including properties of reference members

Example:

 public class B
    {
        [IsSearchable]
        [IsEncryptable]
        public string bPropA { get; set; }
        [IsSearchable]
        [IsEncryptable]
        public string bPropB { get; set; }
    }
    class A
    {
        [IsSearchable]
        [IsEncryptable]
        public string PropA { get; set; }
        [IsSearchable]
        [IsEncryptable]
        public string PropB { get; set; }
        [IsSearchable]
        public int PropC { get; set; }
        [IsSearchable]
        public B PropD { get; set; }
    }

So out of the example above I want all 6 properties when sending an object of class A to a function. So far I've tried:

    A a = new A();
    a.GetType().GetAllProperties();

But it only returns the 4 properties and not it's members properties. Looked around but couldn't find any question regarding this matter at least not specifically.





Aucun commentaire:

Enregistrer un commentaire