public bool AddSpouse(GEDCOMIndividualRecord spouse)
        {
            if (spouse == null)
            {
                return(false);
            }

            GEDCOMSex sex = spouse.Sex;

            if (sex == GEDCOMSex.svNone || sex == GEDCOMSex.svUndetermined)
            {
                return(false);
            }

            switch (sex)
            {
            case GEDCOMSex.svMale:
                Husband.Value = spouse;
                break;

            case GEDCOMSex.svFemale:
                Wife.Value = spouse;
                break;
            }

            GEDCOMSpouseToFamilyLink spLink = new GEDCOMSpouseToFamilyLink(Owner, spouse, "", "");

            spLink.Family = this;
            spouse.SpouseToFamilyLinks.Add(spLink);

            return(true);
        }
Beispiel #2
0
        public override void MoveTo(GEDCOMRecord targetRecord, bool clearDest)
        {
            GEDCOMIndividualRecord toRec = targetRecord as GEDCOMIndividualRecord;

            if (toRec == null)
            {
                throw new ArgumentException(@"Argument is null or wrong type", "targetRecord");
            }

            if (!clearDest)
            {
                DeleteTag("SEX");
                DeleteTag("_UID");
            }

            base.MoveTo(targetRecord, clearDest);

            while (fPersonalNames.Count > 0)
            {
                GEDCOMPersonalName obj = fPersonalNames.Extract(0);
                obj.ResetParent(toRec);
                toRec.AddPersonalName(obj);
            }

            if (toRec.ChildToFamilyLinks.Count == 0 && ChildToFamilyLinks.Count != 0 && fChildToFamilyLinks != null)
            {
                GEDCOMChildToFamilyLink ctfLink = fChildToFamilyLinks.Extract(0);
                GEDCOMFamilyRecord      family  = ctfLink.Family;

                int num = family.Children.Count;
                for (int i = 0; i < num; i++)
                {
                    GEDCOMPointer childPtr = family.Children[i];

                    if (childPtr.StringValue == "@" + XRef + "@")
                    {
                        childPtr.StringValue = "@" + targetRecord.XRef + "@";
                    }
                }

                ctfLink.ResetParent(toRec);
                toRec.ChildToFamilyLinks.Add(ctfLink);
            }

            while (fSpouseToFamilyLinks.Count > 0)
            {
                GEDCOMSpouseToFamilyLink stfLink = fSpouseToFamilyLinks.Extract(0);
                GEDCOMFamilyRecord       family  = stfLink.Family;

                string targetXRef = "@" + targetRecord.XRef + "@";

                if (family.Husband.StringValue == "@" + XRef + "@")
                {
                    family.Husband.StringValue = targetXRef;
                }
                else if (family.Wife.StringValue == "@" + XRef + "@")
                {
                    family.Wife.StringValue = targetXRef;
                }

                stfLink.ResetParent(toRec);
                toRec.SpouseToFamilyLinks.Add(stfLink);
            }

            while (fIndividualOrdinances.Count > 0)
            {
                GEDCOMIndividualOrdinance ord = fIndividualOrdinances.Extract(0);
                ord.ResetParent(toRec);
                toRec.IndividualOrdinances.Add(ord);
            }

            while (fSubmittors.Count > 0)
            {
                GEDCOMPointer obj = fSubmittors.Extract(0);
                obj.ResetParent(toRec);
                toRec.Submittors.Add(obj);
            }

            while (fAssociations.Count > 0)
            {
                GEDCOMAssociation obj = fAssociations.Extract(0);
                obj.ResetParent(toRec);
                toRec.Associations.Add(obj);
            }

            while (fAliasses.Count > 0)
            {
                GEDCOMAlias obj = fAliasses.Extract(0);
                obj.ResetParent(toRec);
                toRec.Aliases.Add(obj);
            }

            while (fAncestorsInterest.Count > 0)
            {
                GEDCOMPointer obj = fAncestorsInterest.Extract(0);
                obj.ResetParent(toRec);
                toRec.AncestorsInterest.Add(obj);
            }

            while (fDescendantsInterest.Count > 0)
            {
                GEDCOMPointer obj = fDescendantsInterest.Extract(0);
                obj.ResetParent(toRec);
                toRec.DescendantsInterest.Add(obj);
            }

            while (fGroups.Count > 0)
            {
                GEDCOMPointer obj = fGroups.Extract(0);
                obj.ResetParent(toRec);
                toRec.Groups.Add(obj);
            }
        }