Reputation: 549
Let's see if I can explain what I'm trying to do...
Say I have an object, with a path to a property that looks like this:
Appointment.Person.Name
If I want to update the "Person" property, i could do something like this:
PropertyInfo subPropertyInfo = apptObject.GetType().GetProperty("Person");
subPropertyInfo.SetValue(apptObject, replacementValue, null);
But how would I update the Name Property for the root object?
Upvotes: 1
Views: 66
Reputation: 32212
Get hold of the current value of Person
, then update it in the same way as you currently are:
PropertyInfo subPropertyInfo = apptObject.GetType().GetProperty("Person");
Object p = subPropertyInfo.GetValue(apptObject);
PropertyInfo subSubPropertyInfo = p.GetType().GetProperty("Name");
subSubPropertyInfo.SetValue(p, replacementValue, null);
Upvotes: 2
Reputation: 1823
How about:
PropertyInfo subPropertyInfo = apptObject.Person.GetType().GetProperty("Name");
subPropertyInfo.SetValue(apptObject.Person, replacementValue, null);
Upvotes: 0