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?

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top