Sometimes one wants to match items between collections by some key first, and then
compare the matched objects. Without this, the comparer basically says there is no
match in collection B for any given item in collection A that doesn't Compare with a result of true.
The results of this aren't particularly useful for object graphs that are mostly the same, but not quite.
Enter CollectionMatchingSpec
The enumerable strings should be property (not field, for now, to keep it simple) names of the
Type when encountered that will be used for matching
You can use complex type properties, too, as part of the key to match. To match on all props/fields on
such a matching key, Don't set this property (default comparer behavior)
NOTE: types are looked up as exact. e.g. if foo is an entry in the dictionary and bar is a
sub-class of foo, upon encountering a bar type, the comparer will not find the entry of foo
Syntax
Visual Basic (Declaration) | |
---|
<System.Runtime.Serialization.DataMemberAttribute()>
Public Property CollectionMatchingSpec As System.Collections.Generic.Dictionary(Of Type,IEnumerable(Of String)) |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As ComparisonConfig
Dim value As System.Collections.Generic.Dictionary(Of Type,IEnumerable(Of String))
instance.CollectionMatchingSpec = value
value = instance.CollectionMatchingSpec |
C# | |
---|
[System.Runtime.Serialization.DataMember()]
public System.Collections.Generic.Dictionary<Type,IEnumerable<string>> CollectionMatchingSpec {get; set;} |
Managed Extensions for C++ | |
---|
[System.Runtime.Serialization.DataMember()]
public: __property System.Collections.Generic.Dictionary<Type*,IEnumerable<string*>*>* get_CollectionMatchingSpec();
public: __property void set_CollectionMatchingSpec(
System.Collections.Generic.Dictionary<Type*,IEnumerable<string*>*>* value
); |
Requirements
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
See Also