Ejemplo n.º 1
0
        /// <summary>
        /// Compares this place record to another record.
        /// </summary>
        /// <param name="place">A place record.</param>
        /// <returns>
        /// &lt;0 if the this record precedes the other in the sort order;
        /// &gt;0 if the other record precedes this one;
        /// 0 if the records are equal
        /// </returns>
        public int CompareTo(GedcomPlace place)
        {
            if (place == null)
            {
                return(1);
            }

            var compare = string.Compare(Form, place.Form);

            if (compare != 0)
            {
                return(compare);
            }

            compare = string.Compare(Latitude, place.Latitude);
            if (compare != 0)
            {
                return(compare);
            }

            compare = string.Compare(Longitude, place.Longitude);
            if (compare != 0)
            {
                return(compare);
            }

            compare = string.Compare(Name, place.Name);
            if (compare != 0)
            {
                return(compare);
            }

            compare = GedcomGenericListComparer.CompareListOrder(PhoneticVariations, place.PhoneticVariations);
            if (compare != 0)
            {
                return(compare);
            }

            compare = GedcomGenericListComparer.CompareListOrder(RomanizedVariations, place.RomanizedVariations);
            if (compare != 0)
            {
                return(compare);
            }

            return(compare);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compares two GedcomName instances by using the full name.
        /// </summary>
        /// <param name="other">The name to compare against this instance.</param>
        /// <returns>An integer specifying the relative sort order.</returns>
        public int CompareTo(GedcomName other)
        {
            if (other == null)
            {
                return(1);
            }

            var compare = string.Compare(Type, other.Type);

            if (compare != 0)
            {
                return(compare);
            }

            compare = GedcomGenericListComparer.CompareListOrder(PhoneticVariations, other.PhoneticVariations);
            if (compare != 0)
            {
                return(compare);
            }

            compare = GedcomGenericListComparer.CompareListOrder(RomanizedVariations, other.RomanizedVariations);
            if (compare != 0)
            {
                return(compare);
            }

            compare = string.Compare(Surname, other.Surname);
            if (compare != 0)
            {
                return(compare);
            }

            compare = string.Compare(Prefix, other.Prefix);
            if (compare != 0)
            {
                return(compare);
            }

            compare = string.Compare(Given, other.Given);
            if (compare != 0)
            {
                return(compare);
            }

            compare = string.Compare(SurnamePrefix, other.SurnamePrefix);
            if (compare != 0)
            {
                return(compare);
            }

            compare = string.Compare(Suffix, other.Suffix);
            if (compare != 0)
            {
                return(compare);
            }

            compare = string.Compare(Nick, other.Nick);
            if (compare != 0)
            {
                return(compare);
            }

            compare = PreferredName.CompareTo(other.PreferredName);
            if (compare != 0)
            {
                return(compare);
            }

            return(compare);
        }