mercredi 6 avril 2016

Setting a property generically

I have a model class that contains a range of properties. I am writing an MVVM Light service that will allow me to directly assign those properties which means I need to create both an interface and service.

Is there a way that I can do something like this

myService.SetProperty(propertyName, value)

and

var n = myService.GetProperty(propertyName)

where propertyName is always a string, but using reflection the correct property is found within the model class and set or read?





Aucun commentaire:

Enregistrer un commentaire