mardi 31 mars 2020

Get Objects From Reflections

I have a class that has string properties that look like so:

 public bool EventLogging { get; set; } = false;   

I'm scrolling threw the class using reflection to get the property and value like so:

 foreach (System.Reflection.PropertyInfo p in this.GetType().GetProperties())
 {
   var propName = p.Name;
   var propValue = p.GetValue(this);
 }

But what I want to do is access a property object (defined below) and read all it's properties.

public Setting EvengLogging { get; set; }

public class Setting
{            
  public string Value { get; set; }
    public string Description { get; set; }
}

All don't see how to access and pull back an object, instead of just reading a property value. Is this even possible?

Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire