Mimic property/list changes on an object on another object

Posted by soundslike on Stack Overflow See other posts from Stack Overflow or by soundslike
Published on 2010-03-16T03:20:55Z Indexed on 2010/03/22 4:11 UTC
Read the original article Hit count: 273

Filed under:
|
|
|

I need to mimic changes (property/list) changes on an object and then apply it to another object to keep the structure/property the same.

In essence it's like cloning etc. the biz rules require certain properties to not be applied to the other object, so I can't just clone the object otherwise this would be easy.

I've already walked the source object to get INotifyPropertyChanged and IListChanged events, so I have the "source" and the args (Property or List) changed event notifications.

Given that I guess I could build a reflection "hierarchy path" starting from the top level of the source object to get to the Property or List changed "source" (which could be several levels deep).

Ignoring for the moment that certain object properties should not propagate to the other object, what's a way to build this "path"? Is a brute force top level down to build the "path" (and discard on the way back up if we don't hit the original changed event "source") the only way to do it?

Any clever ideas on how to mimic changes from one object to another object?

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection