Пример #1
0
        /// <summary>
        /// Compares this event to another record.
        /// </summary>
        /// <param name="other">A recorded event.</param>
        /// <returns>
        /// &lt;0 if the first event precedes the second in the sort order;
        /// &gt;0 if the second event precedes the first;
        /// 0 if the events are equal
        /// </returns>
        public int CompareTo(GedcomRecordedEvent other)
        {
            if (other == null)
            {
                return(1);
            }

            var compare = CompareEvents(Types, other.Types);

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

            compare = GedcomGenericComparer.SafeCompareOrder(Date, other.Date);
            if (compare != 0)
            {
                return(compare);
            }

            compare = GedcomGenericComparer.SafeCompareOrder(Place, other.Place);
            if (compare != 0)
            {
                return(compare);
            }

            return(compare);
        }
Пример #2
0
        /// <summary>
        /// Compares another source citation to the current instance.
        /// </summary>
        /// <param name="citation">A citation.</param>
        /// <returns>
        /// &lt;0 if this citation precedes the other in the sort order;
        /// &gt;0 if the other citation precedes this one;
        /// 0 if the citations are equal
        /// </returns>
        public int CompareTo(GedcomSourceCitation citation)
        {
            if (citation == null)
            {
                return(1);
            }

            var compare = Certainty.CompareTo(citation.Certainty);

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

            compare = GedcomGenericComparer.SafeCompareOrder(Date, citation.Date);
            if (compare != 0)
            {
                return(compare);
            }

            compare = GedcomGenericComparer.SafeCompareOrder(EventType, citation.EventType);
            if (compare != 0)
            {
                return(compare);
            }

            compare = GedcomGenericComparer.SafeCompareOrder(Page, citation.Page);
            if (compare != 0)
            {
                return(compare);
            }

            compare = GedcomGenericComparer.SafeCompareOrder(Role, citation.Role);
            if (compare != 0)
            {
                return(compare);
            }

            compare = GedcomGenericComparer.SafeCompareOrder(Text, citation.Text);
            if (compare != 0)
            {
                return(compare);
            }

            return(compare);
        }
Пример #3
0
        /// <summary>
        /// Compare the user entered data against the passed instance for similarity.
        /// </summary>
        /// <param name="obj">The object to compare this instance against.</param>
        /// <returns>
        /// True if instance matches user data, otherwise false.
        /// </returns>
        public override bool IsEquivalentTo(object obj)
        {
            var eventRecord = obj as GedcomEvent;

            if (eventRecord == null)
            {
                return(false);
            }

            if (!GedcomGenericComparer.SafeEqualityCheck(Address, eventRecord.Address))
            {
                return(false);
            }

            if (!Equals(Cause, eventRecord.Cause))
            {
                return(false);
            }

            if (!Equals(Certainty, eventRecord.Certainty))
            {
                return(false);
            }

            if (!Equals(Classification, eventRecord.Classification))
            {
                return(false);
            }

            if (!Equals(Date, eventRecord.Date))
            {
                return(false);
            }

            if (!Equals(EventName, eventRecord.EventName))
            {
                return(false);
            }

            if (!Equals(EventType, eventRecord.EventType))
            {
                return(false);
            }

            if (!Equals(Place, eventRecord.Place))
            {
                return(false);
            }

            if (!Equals(ReligiousAffiliation, eventRecord.ReligiousAffiliation))
            {
                return(false);
            }

            if (!Equals(ResponsibleAgency, eventRecord.ResponsibleAgency))
            {
                return(false);
            }

            return(true);
        }