dimanche 5 mars 2017

C# Get Attribute of custom class with Reflection

I have a custom class called Dashboard stored as an application variable in my MVC 5 Web App.

While I can read the Dashboard object instance out fine I wish to call a method on this instance to give me back the value of an attribute I name like so

 public object ReadDashboardAttribute(string name)
 {
        var dashboard = (Dashboard)ReadApplicationVariable("Dashboard");
        return dashboard[name];
 }

But it does not work as I would expect.

Am I asking too much of Reflection?





Aucun commentaire:

Enregistrer un commentaire