I have the following problem:
I'm trying to Set a value of a TimeSpan property with reflection but the property reflect as Int64 Ticks with SetMethod null and when I try to make (PropertyInfo).SetValue(...,...) I get a "property set method not found" Exception.
So my question is:
How Can I Set a TimeSpan value of a property by Reflection?
I'm using following code that works for all properties with exception of TimeSpan
private static void PropSetValue(PropertyInfo prop, PropertyInfo updaterProp, object updater, object toUpdate)
{
var propValue = prop.GetValue(toUpdate, null);
var updValue = updaterProp.GetValue(updater, null);
if (!Equals(propValue, updValue))
prop.SetValue(toUpdate, updValue, null);
}
Thankyou in advance for suggestions or workarounds.
Piercarlo
Aucun commentaire:
Enregistrer un commentaire