Ejemplo n.º 1
0
        public void GEDCOMUtils_Tests()
        {
            GEDCOMObject obj = new GEDCOMObject();

            obj.ExtData = this;
            Assert.AreEqual(obj.ExtData, this);
            obj.Dispose();

            //

            Assert.AreEqual("I12", GEDCOMUtils.CleanXRef("@I12@"), "CleanXRef(@I12@)");
            Assert.AreEqual("@I12@", GEDCOMUtils.EncloseXRef("I12"), "EncloseXRef(I12)");

            //
            string s1 = " 12345 efgh";
            string s2 = "";

            s2 = GEDCOMUtils.ExtractDelimiter(s1, 0);
            Assert.AreEqual("12345 efgh", s2);

            //

            string s3 = GEDCOMUtils.ExtractDelimiter("    abrvalg", 2);

            Assert.AreEqual("  abrvalg", s3);
        }
        public CorresponderRet GetCorresponder()
        {
            GKCommunicationDir     commDir      = GKCommunicationDir.cdFrom;
            GEDCOMIndividualRecord corresponder = null;

            GEDCOMTag corrTag = FindTag("FROM", 0);

            if (corrTag == null)
            {
                corrTag = FindTag("TO", 0);
            }

            if (corrTag != null)
            {
                corresponder = (Owner.XRefIndex_Find(GEDCOMUtils.CleanXRef(corrTag.StringValue)) as GEDCOMIndividualRecord);

                if (corrTag.Name == "FROM")
                {
                    commDir = GKCommunicationDir.cdFrom;
                }
                else if (corrTag.Name == "TO")
                {
                    commDir = GKCommunicationDir.cdTo;
                }
            }

            return(new CorresponderRet(commDir, corresponder));
        }
Ejemplo n.º 3
0
        public TaskGoalRet GetTaskGoal()
        {
            GDMTree   tree     = GetTree();
            string    goalXRef = string.Empty;
            GDMRecord goalRec  = tree.XRefIndex_Find(GEDCOMUtils.CleanXRef(Goal));

            GDMGoalType goalType;

            if (goalRec is GDMIndividualRecord)
            {
                goalType = GDMGoalType.gtIndividual;
            }
            else if (goalRec is GDMFamilyRecord)
            {
                goalType = GDMGoalType.gtFamily;
            }
            else if (goalRec is GDMSourceRecord)
            {
                goalType = GDMGoalType.gtSource;
            }
            else
            {
                goalType = GDMGoalType.gtOther;
            }

            return(new TaskGoalRet(goalType, goalXRef, goalRec));
        }
Ejemplo n.º 4
0
        public TaskGoalRet GetTaskGoal()
        {
            GEDCOMTree   tree    = Owner;
            GEDCOMRecord goalRec = tree.XRefIndex_Find(GEDCOMUtils.CleanXRef(Goal));

            GKGoalType goalType;

            if (goalRec is GEDCOMIndividualRecord)
            {
                goalType = GKGoalType.gtIndividual;
            }
            else if (goalRec is GEDCOMFamilyRecord)
            {
                goalType = GKGoalType.gtFamily;
            }
            else if (goalRec is GEDCOMSourceRecord)
            {
                goalType = GKGoalType.gtSource;
            }
            else
            {
                goalType = GKGoalType.gtOther;
            }

            return(new TaskGoalRet(goalType, goalRec));
        }
Ejemplo n.º 5
0
        public void AddXRef(GDMRecord rec, string oldXRef, string newXRef)
        {
            // protection
            oldXRef = GEDCOMUtils.CleanXRef(oldXRef);
            newXRef = GEDCOMUtils.CleanXRef(newXRef);

            fList.Add(new XRefEntry(rec, oldXRef, newXRef));
        }
Ejemplo n.º 6
0
        public override void ReplaceXRefs(GDMXRefReplacer map)
        {
            base.ReplaceXRefs(map);

            if (GEDCOMUtils.IsXRef(fGoal))
            {
                fGoal = GEDCOMUtils.EncloseXRef(map.FindNewXRef(GEDCOMUtils.CleanXRef(fGoal)));
            }
        }
Ejemplo n.º 7
0
        public override void ReplaceXRefs(GDMXRefReplacer map)
        {
            base.ReplaceXRefs(map);

            TaskGoalRet goalRet = GetTaskGoal();

            if (goalRet.GoalType != GDMGoalType.gtOther)
            {
                Goal = GEDCOMUtils.EncloseXRef(map.FindNewXRef(GEDCOMUtils.CleanXRef(Goal)));
            }
        }
Ejemplo n.º 8
0
        public string FindNewXRef(string oldXRef)
        {
            string result = oldXRef;

            foreach (XRefEntry entry in fList)
            {
                if (GEDCOMUtils.CleanXRef(entry.OldXRef) == GEDCOMUtils.CleanXRef(oldXRef))
                {
                    result = entry.NewXRef;
                    break;
                }
            }

            return(result);
        }
Ejemplo n.º 9
0
 public void Test_XRef_CleanEnclose()
 {
     Assert.AreEqual("I12", GEDCOMUtils.CleanXRef("@I12@"), "CleanXRef(@I12@)");
     Assert.AreEqual("@I12@", GEDCOMUtils.EncloseXRef("I12"), "EncloseXRef(I12)");
 }