/// <summary> /// Add the given record to the database with the given XRef /// </summary> /// <param name="xrefID"> /// A <see cref="string"/> /// </param> /// <param name="record"> /// A <see cref="GedcomRecord"/> /// </param> public virtual void Add(string xrefID, GedcomRecord record) { Table.Add(xrefID, record); if (record is GedcomIndividualRecord) { GedcomIndividualRecord indi = (GedcomIndividualRecord)record; int pos = individuals.BinarySearch(indi); if (pos < 0) { pos = ~pos; } individuals.Insert(pos, indi); } else if (record is GedcomFamilyRecord) { families.Add((GedcomFamilyRecord)record); } else if (record is GedcomSourceRecord) { GedcomSourceRecord source = (GedcomSourceRecord)record; int pos = sources.BinarySearch(source); if (pos < 0) { pos = ~pos; } sources.Insert(pos, source); } else if (record is GedcomRepositoryRecord) { GedcomRepositoryRecord repo = (GedcomRepositoryRecord)record; int pos = repositories.BinarySearch(repo); if (pos < 0) { pos = ~pos; } repositories.Insert(pos, repo); } else if (record is GedcomMultimediaRecord) { media.Add((GedcomMultimediaRecord)record); } else if (record is GedcomNoteRecord) { notes.Add((GedcomNoteRecord)record); } else if (record is GedcomSubmitterRecord) { submitters.Add((GedcomSubmitterRecord)record); } record.Database = this; }
/// <summary> /// Deletes this instance. /// </summary> public override void Delete() { base.Delete(); GedcomRepositoryRecord repo = (GedcomRepositoryRecord)Database[Repository]; repo.Citations.Remove(this); repo.Delete(); }
/// <summary> /// Compares this repository record to another record. /// </summary> /// <param name="repoB">A repository record.</param> /// <returns> /// <0 if the this record precedes the other in the sort order; /// >0 if the other record precedes this one; /// 0 if the records are equal /// </returns> public int CompareTo(object repoB) { return(GedcomRepositoryRecord.CompareByName(this, (GedcomRepositoryRecord)repoB)); }
/// <summary> /// Compares the names of the passed records. /// </summary> /// <param name="repoA">The first repository record.</param> /// <param name="repoB">The second repository record.</param> /// <returns> /// <0 if the first record's name precedes the second in the sort order; /// >0 if the second record's name precedes the first; /// 0 if the names are equal /// </returns> public static int CompareByName(GedcomRepositoryRecord repoA, GedcomRepositoryRecord repoB) { return(string.Compare(repoA.Name, repoB.Name)); }