void PerformCompareProperties(Type t1,
object object1,
object object2,
string breadCrumb)
{
IEnumerable<PropertyInfo> currentProperties = GetPropertyInfo(t1);
foreach (PropertyInfo info in currentProperties)
{
//If we can't read it, skip it
if (info.CanRead == false)
continue;
//Skip if this is a shallow compare
if (!CompareChildren && IsChildType(info.PropertyType))
continue;
//If we should ignore it, skip it
if (ElementsToIgnore.Contains(info.Name) || IgnoredByAttribute(info.PropertyType))
continue;
//If we should ignore read only, skip it
if (!CompareReadOnly && info.CanWrite == false)
continue;
object objectValue1;
object objectValue2;
if (!IsValidIndexer(info, breadCrumb))
{
objectValue1 = info.GetValue(object1, null);
objectValue2 = info.GetValue(object2, null);
}
else
{
CompareIndexer(info, object1, object2, breadCrumb);
continue;
}
bool object1IsParent = objectValue1 != null &&
(objectValue1 == object1 || _parents.Contains(objectValue1));
bool object2IsParent = objectValue2 != null &&
(objectValue2 == object2 || _parents.Contains(objectValue2));
//Skip properties where both point to the corresponding parent
if ((IsClass(info.PropertyType) || IsStruct(info.PropertyType)) && (object1IsParent && object2IsParent))
{
continue;
}
string currentCrumb = AddBreadCrumb(breadCrumb, info.Name, string.Empty, -1);
Compare(objectValue1, objectValue2, currentCrumb);
if (Differences.Count >= MaxDifferences)
return;
}
}