예제 #1
0
        /// <summary>
        /// Deletes this instance.
        /// </summary>
        /// <exception cref="Exception">Ref Count already 0</exception>
        public virtual void Delete()
        {
            /* if (RefCount == 0) // This was causing individual deletes not to happen properly.
             * {
             *  // TODO: Not good, need to feed back to user instead of blowing up.
             *  throw new Exception("Ref Count already 0");
             * } */

            RefCount--;
            if (RefCount <= 0)
            {
                if (multimedia != null)
                {
                    foreach (string objeID in multimedia)
                    {
                        GedcomMultimediaRecord obje = (GedcomMultimediaRecord)Database[objeID];
                        obje.Delete();
                    }
                }

                if (sources != null)
                {
                    foreach (GedcomSourceCitation citation in sources)
                    {
                        citation.Delete();
                    }
                }

                if (notes != null)
                {
                    foreach (string noteID in notes)
                    {
                        GedcomNoteRecord note = (GedcomNoteRecord)Database[noteID];
                        note.Delete();
                    }
                }

                if (!string.IsNullOrEmpty(XrefId))
                {
                    Database.Remove(XrefId, this);
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Compares the two passed records by title.
 /// </summary>
 /// <param name="mediaA">The first multimedia record.</param>
 /// <param name="mediaB">The second multimedia record.</param>
 /// <returns>
 /// &lt;0 if the first record's title precedes the second in the sort order;
 /// &gt;0 if the second record's title precedes the first;
 /// 0 if the titles are equal
 /// </returns>
 public static int CompareByTitle(GedcomMultimediaRecord mediaA, GedcomMultimediaRecord mediaB)
 {
     return(string.Compare(mediaA.Title, mediaB.Title));
 }