protected override MATCH_RESULT InternalCompare(Person a, Person b) { MATCH_RESULT result = MATCH_RESULT.INCONCLUSIVE; Adult adult1 = (Adult)a; Adult adult2 = (Adult)b; if ((adult1.Phone1 != null || adult1.Phone2 != null) && (adult2.Phone1 != null || adult2.Phone2 != null)) { string a1p1 = (adult1.Phone1 != null)? new string(adult1.Phone1.Where(c => char.IsDigit(c)).ToArray()) : ""; string a1p2 = (adult1.Phone2 != null)? new string(adult1.Phone2.Where(c => char.IsDigit(c)).ToArray()) : ""; string a2p1 = (adult2.Phone1 != null)? new string(adult2.Phone1.Where(c => char.IsDigit(c)).ToArray()) : ""; string a2p2 = (adult2.Phone2 != null)? new string(adult2.Phone2.Where(c => char.IsDigit(c)).ToArray()) : ""; if ((PartialStringMatch(a1p1, a2p1) || PartialStringMatch(a1p1, a2p2)) || (PartialStringMatch(a1p2, a2p1) || PartialStringMatch(a1p2, a2p2))) { result = MATCH_RESULT.EQUAL; } else if ((a1p1.Length > 0 || a1p2.Length > 0) && (a2p1.Length > 0 || a2p2.Length > 0)) { result = MATCH_RESULT.NOT_EQUAL; } } return(result); }
protected override MATCH_RESULT InternalCompare(Person a, Person b) { MATCH_RESULT result = MATCH_RESULT.INCONCLUSIVE; int score = 0; IList <PropertyInfo> personProperties = new List <PropertyInfo>(typeof(Person).GetProperties()); foreach (PropertyInfo prop in personProperties) { object valueA = prop.GetValue(a, null); object valueB = prop.GetValue(b, null); if (valueA != null && valueB != null) { int weight = WeightMap[prop.Name]; if (valueA.GetType() == typeof(int)) { score = ((int)valueA == (int)valueB) ? score += weight : score -= weight; } else if (valueA.GetType() == typeof(String) || valueA.GetType() == typeof(string)) { String s1 = (String)valueA; String s2 = (String)valueB; if (PartialStringMatch(s1, s2)) { score += weight; } else { score -= weight; } } } } if (score != 0) { result = (score > 0) ? MATCH_RESULT.EQUAL : MATCH_RESULT.NOT_EQUAL; } return(result); }