Ejemplo n.º 1
0
        public bool AddSpouse(GDMIndividualRecord spouse)
        {
            if (spouse == null)
            {
                return(false);
            }

            GDMSex sex = spouse.Sex;

            if (sex == GDMSex.svUnknown || sex == GDMSex.svIntersex)
            {
                return(false);
            }

            switch (sex)
            {
            case GDMSex.svMale:
                fHusband.Value = spouse;
                break;

            case GDMSex.svFemale:
                fWife.Value = spouse;
                break;
            }

            GDMSpouseToFamilyLink spLink = new GDMSpouseToFamilyLink(spouse);

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

            return(true);
        }
Ejemplo n.º 2
0
        public static void Test_GDMSpouseToFamilyLink(GDMSpouseToFamilyLink spouseLink)
        {
            Assert.IsNotNull(spouseLink.Family);

            using (spouseLink = new GDMSpouseToFamilyLink(null)) {
                Assert.IsNotNull(spouseLink);
            }
        }
Ejemplo n.º 3
0
        public static void Test_GDMSpouseToFamilyLink(GDMTree tree, GDMSpouseToFamilyLink spouseLink)
        {
            Assert.IsNotNull(tree.GetPtrValue <GDMFamilyRecord>(spouseLink));

            using (spouseLink = new GDMSpouseToFamilyLink()) {
                Assert.IsNotNull(spouseLink);
            }
        }
Ejemplo n.º 4
0
        public override void MoveTo(GDMRecord targetRecord, bool clearDest)
        {
            GDMIndividualRecord targetIndi = targetRecord as GDMIndividualRecord;

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

            /*if (!clearDest) {
             *  DeleteTag(GEDCOMTagType.SEX);
             *  DeleteTag(GEDCOMTagType._UID);
             * }*/

            base.MoveTo(targetRecord, clearDest);

            targetIndi.Sex = fSex;

            while (fPersonalNames.Count > 0)
            {
                GDMPersonalName obj = fPersonalNames.Extract(0);
                obj.ResetOwner(targetIndi);
                targetIndi.AddPersonalName(obj);
            }

            string currentXRef = this.XRef;
            string targetXRef  = targetRecord.XRef;

            while (fChildToFamilyLinks.Count > 0)
            {
                GDMChildToFamilyLink ctfLink = fChildToFamilyLinks.Extract(0);
                GDMFamilyRecord      family  = ctfLink.Family;

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

                    if (childPtr.XRef == currentXRef)
                    {
                        childPtr.XRef = targetXRef;
                    }
                }

                ctfLink.ResetOwner(targetIndi);
                targetIndi.ChildToFamilyLinks.Add(ctfLink);
            }

            while (fSpouseToFamilyLinks.Count > 0)
            {
                GDMSpouseToFamilyLink stfLink = fSpouseToFamilyLinks.Extract(0);
                GDMFamilyRecord       family  = stfLink.Family;

                if (family.Husband.XRef == currentXRef)
                {
                    family.Husband.XRef = targetXRef;
                }
                else if (family.Wife.XRef == currentXRef)
                {
                    family.Wife.XRef = targetXRef;
                }

                stfLink.ResetOwner(targetIndi);
                targetIndi.SpouseToFamilyLinks.Add(stfLink);
            }

            while (fAssociations.Count > 0)
            {
                GDMAssociation obj = fAssociations.Extract(0);
                obj.ResetOwner(targetIndi);
                targetIndi.Associations.Add(obj);
            }

            while (fAliases.Count > 0)
            {
                GDMAlias obj = fAliases.Extract(0);
                obj.ResetOwner(targetIndi);
                targetIndi.Aliases.Add(obj);
            }

            while (fGroups.Count > 0)
            {
                GDMPointer obj = fGroups.Extract(0);
                obj.ResetOwner(targetIndi);
                targetIndi.Groups.Add(obj);
            }
        }
Ejemplo n.º 5
0
        public override void MoveTo(GDMRecord targetRecord)
        {
            GDMIndividualRecord targetIndi = targetRecord as GDMIndividualRecord;

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

            base.MoveTo(targetRecord);

            targetIndi.Sex = fSex;

            while (fPersonalNames.Count > 0)
            {
                GDMPersonalName obj = fPersonalNames.Extract(0);
                targetIndi.AddPersonalName(obj);
            }

            string currentXRef = this.XRef;
            string targetXRef  = targetRecord.XRef;

            while (fChildToFamilyLinks.Count > 0)
            {
                GDMChildToFamilyLink ctfLink = fChildToFamilyLinks.Extract(0);
                var family = fTree.GetPtrValue <GDMFamilyRecord>(ctfLink);

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

                    if (childPtr.XRef == currentXRef)
                    {
                        childPtr.XRef = targetXRef;
                    }
                }

                targetIndi.ChildToFamilyLinks.Add(ctfLink);
            }

            while (fSpouseToFamilyLinks.Count > 0)
            {
                GDMSpouseToFamilyLink stfLink = fSpouseToFamilyLinks.Extract(0);
                var family = fTree.GetPtrValue <GDMFamilyRecord>(stfLink);

                if (family.Husband.XRef == currentXRef)
                {
                    family.Husband.XRef = targetXRef;
                }
                else if (family.Wife.XRef == currentXRef)
                {
                    family.Wife.XRef = targetXRef;
                }

                targetIndi.SpouseToFamilyLinks.Add(stfLink);
            }

            while (fAssociations.Count > 0)
            {
                GDMAssociation obj = fAssociations.Extract(0);
                targetIndi.Associations.Add(obj);
            }

            while (fGroups.Count > 0)
            {
                GDMPointer obj = fGroups.Extract(0);
                targetIndi.Groups.Add(obj);
            }
        }