I'm doing "deep comparison" of data structures for audit logging (who changed what members, when). I'm using reflection for this, recursing into the structures and comparing them. I've hit a problem though with those containing dictionaries.
I can detect that a member is a dictionary by typeof(IDictionary).IsAssignableFrom(memberType)
. My plan is then to collect the keys which are present in both objects, and continue recursion on those. However, IDictionary.Keys
is an ICollection
, which is not extended by LINQ. Not knowing the type of the keys, how could I achieve this?
Maybe this method is suboptimal (I'm not that experienced in the Generics/Reflection combo), should I do this in another way?
Found a solution myself. Here
ChangedProperties
is a type containing property name, and values pre/post change.