Exemplo n.º 1
0
        public void testAhnenblattDate()
        {
            string gedcom = "0 HEAD\n1 SOUR AHN\n0 @I1@ INDI\n1 BIRT\n2 DATE (20/12-1980)";

            // TODO this bit needs to go into utility class
            GEDCOMTree     tee = new GEDCOMTree();
            GEDCOMProvider gp  = new GEDCOMProvider(tee);

            try {
                gp.LoadFromString(gedcom);
            } catch (Exception) {
            }
            Assert.AreEqual(1, tee.RecordsCount);
            GEDCOMRecord rec = tee[0];

            Assert.IsTrue(rec is GEDCOMIndividualRecord);
            GEDCOMIndividualRecord rec2 = (GEDCOMIndividualRecord)rec;
            // end for utility class

            GEDCOMList <GEDCOMCustomEvent> events = rec2.Events;

            Assert.AreEqual(1, events.Count);
            GEDCOMCustomEvent birt = events.Extract(0);
            GEDCOMDateValue   dv   = birt.Date;

            Assert.AreEqual("20 DEC 1980", dv.StringValue);
        }
Exemplo n.º 2
0
        public bool DeleteLocationRecord(GEDCOMLocationRecord locRec)
        {
            if (locRec == null)
            {
                return(false);
            }

            int num = fRecords.Count;

            for (int i = 0; i < num; i++)
            {
                var evsRec = this[i] as GEDCOMRecordWithEvents;
                if (evsRec != null)
                {
                    for (int j = evsRec.Events.Count - 1; j >= 0; j--)
                    {
                        GEDCOMCustomEvent ev = evsRec.Events[j];

                        if (ev.Place.Location.Value == locRec)
                        {
                            ev.Place.DeleteTag("_LOC");
                        }
                    }
                }
            }

            DeleteRecord(locRec);
            return(true);
        }
Exemplo n.º 3
0
        private static void GEDCOMListTest21(GEDCOMIndividualRecord iRec)
        {
            int hash;

            for (int i = 0; i < iRec.Events.Count; i++)
            {
                GEDCOMCustomEvent evt1 = iRec.Events[i];
                hash = evt1.GetHashCode();
            }
        }
Exemplo n.º 4
0
        private static void GEDCOMListTest23(GEDCOMIndividualRecord iRec)
        {
            int hash;
            GEDCOMList <GEDCOMCustomEvent> events = iRec.Events;

            for (int i = 0, num = events.Count; i < num; i++)
            {
                GEDCOMCustomEvent evt1 = events[i];
                hash = evt1.GetHashCode();
            }
        }
Exemplo n.º 5
0
        private static void GEDCOMListTest12(GEDCOMIndividualRecord iRec)
        {
            int hash;
            IGEDCOMListEnumerator <GEDCOMCustomEvent> enumer = iRec.Events.GetEnumerator();

            while (enumer.MoveNext())
            {
                GEDCOMCustomEvent evt1 = enumer.Current;
                hash = evt1.GetHashCode();
            }
        }
        public float GetCertaintyAssessment()
        {
            float result = 0;
            float wsum   = 0;

            int num1 = fEvents.Count;

            for (int i = 0; i < num1; i++)
            {
                GEDCOMCustomEvent evt = fEvents[i];

                int num2 = evt.SourceCitations.Count;
                for (int k = 0; k < num2; k++)
                {
                    GEDCOMSourceCitation cit = evt.SourceCitations[k];

                    int ca     = CheckCA(cit.CertaintyAssessment);
                    int weight = (ca + 1);

                    result += (CA_VALUES[ca] * weight);
                    wsum   += weight;
                }
            }

            int num3 = SourceCitations.Count;

            for (int i = 0; i < num3; i++)
            {
                GEDCOMSourceCitation cit = SourceCitations[i];

                int ca     = CheckCA(cit.CertaintyAssessment);
                int weight = (ca + 1);

                result += (CA_VALUES[ca] * weight);
                wsum   += weight;
            }

            if (wsum != 0.0f)
            {
                result /= wsum;
            }
            else
            {
                result = 0.0f;
            }

            return(result);
        }
Exemplo n.º 7
0
        public override GEDCOMCustomEvent AddEvent(GEDCOMCustomEvent evt)
        {
            if (evt != null)
            {
                if (evt is GEDCOMFamilyEvent)
                {
                    // SetLevel need for events created outside!
                    evt.SetLevel(Level + 1);
                    Events.Add(evt);
                }
                else
                {
                    throw new ArgumentException(@"Event has the invalid type", "evt");
                }
            }

            return(evt);
        }
        public override void MoveTo(GEDCOMRecord targetRecord, bool clearDest)
        {
            GEDCOMRecordWithEvents target = targetRecord as GEDCOMRecordWithEvents;

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

            base.MoveTo(targetRecord, clearDest);

            while (fEvents.Count > 0)
            {
                GEDCOMCustomEvent obj = fEvents.Extract(0);
                obj.ResetParent(target);
                target.AddEvent(obj);
            }
        }
        public override void Assign(GEDCOMTag source)
        {
            GEDCOMRecordWithEvents sourceRec = source as GEDCOMRecordWithEvents;

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

            base.Assign(source);

            foreach (GEDCOMCustomEvent sourceEvent in sourceRec.fEvents)
            {
                GEDCOMCustomEvent copy = (GEDCOMCustomEvent)Activator.CreateInstance(sourceEvent.GetType(), new object[] { Owner, this, "", "" });
                copy.Assign(sourceEvent);
                AddEvent(copy);
            }
        }
Exemplo n.º 10
0
        public GEDCOMCustomEvent FindEvent(string eventName)
        {
            GEDCOMCustomEvent result = null;

            int num = fEvents.Count;

            for (int i = 0; i < num; i++)
            {
                GEDCOMCustomEvent evt = fEvents[i];

                if (evt.Name == eventName)
                {
                    result = evt;
                    break;
                }
            }

            return(result);
        }
Exemplo n.º 11
0
        public override float IsMatch(GEDCOMTag tag, MatchParams matchParams)
        {
            if (tag == null)
            {
                return(0.0f);
            }
            GEDCOMCustomEvent ev = (GEDCOMCustomEvent)tag;

            // match date
            float dateMatch = 0.0f;
            float locMatch  = 0.0f;
            int   matches   = 0;

            GEDCOMDateValue dtVal  = this.Date;
            GEDCOMDateValue dtVal2 = ev.Date;

            matches += 1;
            if (dtVal != null && dtVal2 != null)
            {
                dateMatch = dtVal.IsMatch(dtVal2, matchParams);
            }

            // match location - late code-on by option implementation
            if (matchParams.CheckEventPlaces)
            {
                matches += 1;

                if (this.Place == null && ev.Place == null)
                {
                    locMatch = 100.0f;
                }
                else if (this.Place != null && ev.Place != null && this.Place.StringValue == ev.Place.StringValue)
                {
                    locMatch = 100.0f;
                }
            }

            float match = (dateMatch + locMatch) / matches;

            return(match);
        }
Exemplo n.º 12
0
        public LifeDatesRet GetLifeDates()
        {
            GEDCOMCustomEvent birthEvent = null;
            GEDCOMCustomEvent deathEvent = null;

            int num = Events.Count;

            for (int i = 0; i < num; i++)
            {
                GEDCOMCustomEvent evt = Events[i];

                if (evt.Name == "BIRT" && birthEvent == null)
                {
                    birthEvent = evt;
                }
                else if (evt.Name == "DEAT" && deathEvent == null)
                {
                    deathEvent = evt;
                }
            }

            return(new LifeDatesRet(birthEvent, deathEvent));
        }
Exemplo n.º 13
0
        // Support function. Parse GEDCOM string, returns ADDR object found
        private GEDCOMAddress AddrParse(string text)
        {
            // TODO should go into general utility class
            GEDCOMTree     tee = new GEDCOMTree();
            GEDCOMProvider gp  = new GEDCOMProvider(tee);

            try {
                gp.LoadFromString(text);
            } catch (Exception) {
            }
            Assert.AreEqual(1, tee.RecordsCount);
            GEDCOMRecord rec = tee[0];

            Assert.IsTrue(rec is GEDCOMIndividualRecord);
            GEDCOMIndividualRecord rec2 = (GEDCOMIndividualRecord)rec;
            // end for utility class

            GEDCOMList <GEDCOMCustomEvent> events = rec2.Events;

            Assert.AreEqual(1, events.Count);
            GEDCOMCustomEvent evt = events[0];

            return(evt.Address);
        }
Exemplo n.º 14
0
 public LifeDatesRet(GEDCOMCustomEvent birthEvent, GEDCOMCustomEvent deathEvent)
 {
     BirthEvent = birthEvent;
     DeathEvent = deathEvent;
 }
Exemplo n.º 15
0
        /// <summary>
        /// In the historical chronology of the year 0 does not exist.
        /// Therefore, the digit 0 in the year value can be used as a sign of lack or error.
        /// ChronologicalYear - introduced for the purposes of uniform chronology years in the Gregorian calendar.
        /// Is estimated from -4714 BC to 3268 AD.
        /// </summary>
        /// <returns>chronological year</returns>
        public int GetChronologicalYear(string eventSign)
        {
            GEDCOMCustomEvent evt = FindEvent(eventSign);

            return((evt == null) ? 0 : evt.GetChronologicalYear());
        }
Exemplo n.º 16
0
        public UDN GetUDN(string eventSign)
        {
            GEDCOMCustomEvent evt = FindEvent(eventSign);

            return((evt == null) ? UDN.CreateEmpty() : evt.GetUDN());
        }
Exemplo n.º 17
0
 public abstract GEDCOMCustomEvent AddEvent(GEDCOMCustomEvent evt);