Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes this instance.
        /// </summary>
        public override void Delete()
        {
            base.Delete();

            GedcomSourceRecord source = (GedcomSourceRecord)Database[Source];

            source.Citations.Remove(this);

            source.Delete();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Generates the XML.
        /// </summary>
        /// <param name="root">The root node.</param>
        public override void GenerateXML(XmlNode root)
        {
            XmlDocument doc = root.OwnerDocument;

            XmlNode      node = doc.CreateElement("Citation");
            XmlAttribute attr;

            if (!string.IsNullOrEmpty(Source))
            {
                GedcomSourceRecord source = Database[Source] as GedcomSourceRecord;
                if (source != null)
                {
                    XmlNode sourceNode = doc.CreateElement("Source");

                    XmlNode linkNode = doc.CreateElement("Link");

                    attr       = doc.CreateAttribute("Target");
                    attr.Value = "SourceRec";
                    linkNode.Attributes.Append(attr);

                    attr       = doc.CreateAttribute("Ref");
                    attr.Value = Source;
                    linkNode.Attributes.Append(attr);

                    sourceNode.AppendChild(linkNode);

                    node.AppendChild(sourceNode);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Pointer to non existant source");
                }

                if (!string.IsNullOrEmpty(Page))
                {
                    XmlNode whereNode = doc.CreateElement("WhereInSource");
                    whereNode.AppendChild(doc.CreateTextNode(Page));

                    node.AppendChild(whereNode);
                }

                if (Date != null)
                {
                    XmlNode whenNode = doc.CreateElement("WhenRecorded");
                    whenNode.AppendChild(doc.CreateTextNode(Date.DateString));
                }

                // TODO: output source citation fields
                //   Caption,     element
                //   Extract,    element
                GenerateNoteXML(node);
            }

            root.AppendChild(node);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Compares this source record to another record.
 /// </summary>
 /// <param name="sourceB">A source record.</param>
 /// <returns>
 /// &lt;0 if the first record precedes the second in the sort order;
 /// &gt;0 if the second record precedes the first;
 /// 0 if the records are equal
 /// </returns>
 public int CompareTo(object sourceB)
 {
     return(GedcomSourceRecord.CompareByTitle(this, (GedcomSourceRecord)sourceB));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Compares two source records by title.
 /// </summary>
 /// <param name="sourceA">The first source record.</param>
 /// <param name="sourceB">The second source 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(GedcomSourceRecord sourceA, GedcomSourceRecord sourceB)
 {
     return(string.Compare(sourceA.Title, sourceB.Title));
 }