Ejemplo n.º 1
0
        // Comparer for sorting list
        public int CompareTo(CListableYear other)
        {
            if (fDate == null)
            {
                return(-1);
            }
            if (other.fDate == null)
            {
                return(1);
            }

            return(fDate.CompareTo(other.fDate));
        }
Ejemplo n.º 2
0
        // Used when sorting events into chronological order. If no dates are explicitly attached to the event, tries to work out an order.
        public int CompareTo(Event other)
        {
            if (fDate != null && other.fDate != null)
            {
                int res = fDate.CompareTo(other.fDate);
                if (res != 0)
                {
                    return(res);
                }

                // Some events naturally precede others: BIRTH, MARRIAGE, DEATH, BURIAL
                int precedence = Precedence - other.Precedence;
                if (precedence != 0)
                {
                    return(precedence);
                }

                // Sort alphabetically if all else fails.
                return(fDescription.CompareTo(other.fDescription));
            }
            else if (other.fDate != null)
            {
                // This goes after valid dates.
                return(1);
            }
            else if (fDate != null)
            {
                // This goes before invalid dates.
                return(-1);
            }

            // Some events naturally precede others: BIRTH, MARRIAGE, DEATH, BURIAL
            int precedence2 = Precedence - other.Precedence;

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

            // Sort alphabetically if all else fails
            return(fDescription.CompareTo(other.fDescription));
        }