/// <summary>
        /// Outputs the specified sw.
        /// </summary>
        /// <param name="sw">The sw.</param>
        public override void Output(TextWriter sw)
        {
            sw.Write(Environment.NewLine);
            sw.Write(Util.IntToString(Level));
            sw.Write(" ");

            sw.Write(GedcomTag);

            if (!string.IsNullOrEmpty(eventName))
            {
                sw.Write(" ");
                sw.Write(eventName);
            }

            OutputStandard(sw);

            string levelPlusOne = null;

            if (!string.IsNullOrEmpty(classification))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(Level + 1);
                }

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" TYPE ");
                sw.Write(classification);
            }

            if (date != null)
            {
                date.Output(sw);
            }

            if (place != null)
            {
                place.Output(sw);
            }

            if (address != null)
            {
                address.Output(sw, Level + 1);
            }

            if (!string.IsNullOrEmpty(responsibleAgency))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(Level + 1);
                }

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" AGNC ");
                string line = responsibleAgency.Replace("@", "@@");
                sw.Write(line);
            }

            if (!string.IsNullOrEmpty(religiousAffiliation))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(Level + 1);
                }

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" RELI ");
                string line = religiousAffiliation.Replace("@", "@@");
                sw.Write(line);
            }

            if (!string.IsNullOrEmpty(cause))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(Level + 1);
                }

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" CAUS ");
                string line = cause.Replace("@", "@@");
                sw.Write(line);
            }

            if (RestrictionNotice != GedcomRestrictionNotice.None)
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(Level + 1);
                }

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" RESN ");
                sw.Write(RestrictionNotice.ToString());
            }

            // Quality of data should only be on source citations according to
            // the spec.
            // We output it on events as well as it has been seen in GEDCOM
            // files from other apps
            if (Certainty != GedcomCertainty.Unknown)
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(Level + 1);
                }

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" QUAY ");
                sw.Write(Util.IntToString((int)Certainty));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Output GEDCOM format for this instance.
        /// </summary>
        /// <param name="sw">Where to output the data to.</param>
        public override void Output(TextWriter sw)
        {
            base.Output(sw);

            string levelPlusOne = Util.IntToString(Level + 1);

            if (RestrictionNotice != GedcomRestrictionNotice.None)
            {
                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" RESN ");
                sw.Write(RestrictionNotice.ToString().ToLower());
            }

            foreach (GedcomFamilyEvent familyEvent in events)
            {
                familyEvent.Output(sw);
            }

            if (!string.IsNullOrEmpty(husband))
            {
                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" HUSB ");
                sw.Write("@");
                sw.Write(husband);
                sw.Write("@");
            }

            if (!string.IsNullOrEmpty(wife))
            {
                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" WIFE ");
                sw.Write("@");
                sw.Write(wife);
                sw.Write("@");
            }

            string levelPlusTwo = Util.IntToString(Level + 2);

            foreach (string childID in children)
            {
                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" CHIL ");
                sw.Write("@");
                sw.Write(childID);
                sw.Write("@");

                GedcomIndividualRecord child = (GedcomIndividualRecord)Database[childID];
                if (child != null)
                {
                    // only output _FREL / _MREL value here,
                    // real PEDI goes on the FAMC on the INDI tag
                    GedcomFamilyLink link = null;
                    if (child.ChildInFamily(XrefId, out link))
                    {
                        switch (link.Pedigree)
                        {
                        case PedigreeLinkageType.FatherAdopted:
                            sw.Write(Environment.NewLine);
                            sw.Write(levelPlusTwo);
                            sw.Write("_FREL Adopted");
                            break;

                        case PedigreeLinkageType.MotherAdopted:
                            sw.Write(Environment.NewLine);
                            sw.Write(levelPlusTwo);
                            sw.Write("_MREL Adopted");
                            break;
                        }
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Missing child linkage for " + childID + " to family " + XrefId);
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Missing child " + childID + " when outputting family " + XrefId);
                }
            }

            if (numberOfChildren != 0)
            {
                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" NCHI ");
                sw.Write("@");
                sw.Write(Util.IntToString(numberOfChildren));
                sw.Write("@");
            }

            if (submitterRecords != null)
            {
                foreach (string submitter in SubmitterRecords)
                {
                    sw.Write(Environment.NewLine);
                    sw.Write(levelPlusOne);
                    sw.Write(" SUBM ");
                    sw.Write("@");
                    sw.Write(submitter);
                    sw.Write("@");
                }
            }

            if (StartStatus != MarriageStartStatus.Unknown)
            {
                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" _MSTAT ");
                sw.Write(StartStatus.ToString());
            }
        }