/// <summary> /// Compares the inheriting instance user entered data against the passed GedcomRecord. /// If that matches, will then compare the common elements of the passed GedcomRecord /// against this instance (Source etc. which are common to all inheritors). /// </summary> /// <param name="obj">The GedcomRecord to compare against.</param> /// <returns>True if the core base properties match, otherwise False.</returns> public bool Equals(GedcomRecord obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } // Ask the inheriting object if its user entered data is the same. if (!IsEquivalentTo(obj)) { return(false); } var record = obj as GedcomRecord; if (!Equals(ChangeDate, record.ChangeDate)) { return(false); } if (!Equals(Level, record.Level)) { return(false); } if (!Equals(RestrictionNotice, record.RestrictionNotice)) { return(false); } if (!GedcomGenericListComparer.CompareGedcomRecordLists(Sources, record.Sources)) { return(false); } if (!GedcomGenericListComparer.CompareLists(Multimedia, record.Multimedia)) { return(false); } /* TODO: Notes are hard work, we need to do lookups by xref instead of just having a list of GedcomNote records attached. Need to fix this as a pain to test and use as well. * //if (!GedcomGenericListComparer.CompareLists(Notes, record.Notes)) * //{ * // return false; * //} */ return(true); }
/// <summary> /// Determines whether the specified <see cref="object" />, is equal (in contents, not structure) to this instance. /// </summary> /// <param name="gedcomDb">The <see cref="object" /> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="object" /> is equal to this instance; otherwise, <c>false</c>. /// </returns> public bool Equals(GedcomDatabase gedcomDb) { if (gedcomDb == null) { return(false); } if (!Equals(Header, gedcomDb.Header)) { return(false); } if (!GedcomGenericListComparer.CompareGedcomRecordLists(Individuals, gedcomDb.Individuals)) { return(false); } return(true); }
/// <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 source = obj as GedcomSourceRecord; if (source == null) { return(false); } if (!Equals(Agency, source.Agency)) { return(false); } if (!GedcomGenericListComparer.CompareGedcomRecordLists(Citations, source.Citations)) { return(false); } if (!GedcomGenericListComparer.CompareLists(DataNotes, source.DataNotes)) { return(false); } if (!GedcomGenericListComparer.CompareLists(EventsRecorded, source.EventsRecorded)) { return(false); } if (!Equals(FiledBy, source.FiledBy)) { return(false); } if (!Equals(Originator, source.Originator)) { return(false); } if (!Equals(Convert.ToString(OriginatorText), Convert.ToString(source.OriginatorText))) { return(false); } if (!Equals(PublicationFacts, source.PublicationFacts)) { return(false); } if (!Equals(Convert.ToString(PublicationText), Convert.ToString(source.PublicationText))) { return(false); } if (!GedcomGenericListComparer.CompareGedcomRecordLists(RepositoryCitations, source.RepositoryCitations)) { return(false); } if (!Equals(Text, source.Text)) { return(false); } if (!Equals(Convert.ToString(TextText), Convert.ToString(source.TextText))) { return(false); } if (!Equals(Title, source.Title)) { return(false); } if (!Equals(Convert.ToString(TitleText), Convert.ToString(source.TitleText))) { return(false); } return(true); }