/// <summary> /// Compares two objects. /// </summary> /// <param name="a"> /// object A. /// </param> /// <param name="b"> /// object B. /// </param> /// <returns> /// One, two or three. /// </returns> public override int Compare(object a, object b) { if (a is null) { return(Constants.CompareEquals); } if (b is null) { return(Constants.CompareEquals); } PersonNameModel firstPersonName = (PersonNameModel)a; PersonNameModel secondPersonName = (PersonNameModel)b; // Compare on Surname first int testFlag = string.Compare(firstPersonName.GSurName.GetPrimarySurname, secondPersonName.GSurName.GetPrimarySurname, StringComparison.CurrentCulture); if (testFlag == Constants.CompareEquals) { // Compare on first name testFlag = string.Compare(firstPersonName.GFirstName, secondPersonName.GFirstName, StringComparison.CurrentCulture); } return(testFlag); }
/// <summary> /// Implement IComparable CompareTo method. /// </summary> /// <param name="obj"> /// The object to compare. /// </param> /// <returns> /// One, two or three. /// </returns> public int CompareTo(object obj) { if (obj is null) { return(0); } PersonNameModel secondEvent = (PersonNameModel)obj; // compare on String first int testFlag = string.Compare(SortName, secondEvent.SortName, StringComparison.CurrentCulture); return(testFlag); }
/// <summary> /// Implement IComparable CompareTo method. /// </summary> /// <param name="obj"> /// The object to compare. /// </param> /// <returns> /// One, two or three. /// </returns> public override int CompareTo(object obj) { if (obj is null) { return(Constants.CompareEquals); } PersonNameModel secondPersonName = obj as PersonNameModel; if (secondPersonName is null) { return(Constants.CompareEquals); } return(CompareTo(secondPersonName)); }
public int CompareTo(PersonNameModel other) { if (other is null) { return(Constants.CompareGreaterThan); } // Compare on Surname first int testFlag = string.Compare(GSurName.GetPrimarySurname, other.GSurName.GetPrimarySurname, StringComparison.CurrentCulture); if (testFlag == Constants.CompareEquals) { // Compare on first name testFlag = string.Compare(GFirstName, other.GFirstName, StringComparison.CurrentCulture); } return(testFlag); }
/// <summary> /// Compares two objects. /// </summary> /// <param name="a"> /// object A. /// </param> /// <param name="b"> /// object B. /// </param> /// <returns> /// One, two or three. /// </returns> public new int Compare(object a, object b) { if (a is null) { return(1); } if (b is null) { return(0); } PersonNameModel firstEvent = (PersonNameModel)a; PersonNameModel secondEvent = (PersonNameModel)b; // compare on Date first int testFlag = string.Compare(firstEvent.SortName, secondEvent.SortName, StringComparison.CurrentCulture); return(testFlag); }