Esempio n. 1
0
        public override void Assign(GDMTag source)
        {
            GDMDate srcDate = source as GDMDate;

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

            fApproximated = srcDate.fApproximated;
            fCalendar     = srcDate.fCalendar;
            fYear         = srcDate.fYear;
            fYearBC       = srcDate.fYearBC;
            fYearModifier = srcDate.fYearModifier;
            fMonth        = srcDate.fMonth;
            fDay          = srcDate.fDay;

            DateChanged();
        }
Esempio n. 2
0
        public override void Assign(GDMTag source)
        {
            GDMSourceCitation sourceObj = (source as GDMSourceCitation);

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

            base.Assign(sourceObj);

            fCertaintyAssessment = sourceObj.fCertaintyAssessment;
            fPage = sourceObj.fPage;
            fData.Assign(sourceObj.fData);
            fDescription.Assign(sourceObj.fDescription);
            fText.Assign(sourceObj.fText);
            AssignList(sourceObj.Notes, fNotes);
            AssignList(sourceObj.MultimediaLinks, fMultimediaLinks);
        }
Esempio n. 3
0
        /// <summary>
        /// Copying the sub-tags from the source to the current tag.
        /// </summary>
        /// <param name="source">A source tag.</param>
        public virtual void Assign(GDMTag source)
        {
            if (source == null)
            {
                return;
            }

            SetName(source.fId);
            ParseString(source.StringValue);

            if (source.fTags != null && source.fTags.Count > 0)
            {
                if (fTags == null)
                {
                    fTags = new GDMList <GDMTag>();
                }
                AssignList(source.fTags, this.fTags);
            }
        }
Esempio n. 4
0
        public void Test_FindTags()
        {
            var tag = new GDMTag(null, GEDCOMTagsTable.Lookup("TEST"), "");

            Assert.IsNotNull(tag);

            tag.AddTag(new GDMTag(tag, (int)GEDCOMTagType._FOLDER, "Private"));
            tag.AddTag(new GDMTag(tag, (int)GEDCOMTagType._FOLDER, "Friends"));
            tag.AddTag(new GDMTag(tag, (int)GEDCOMTagType._FOLDER, "Research"));

            var subTags = tag.FindTags(GEDCOMTagName._FOLDER);

            Assert.AreEqual(3, subTags.Count);

            tag.DeleteTag(GEDCOMTagName._FOLDER);

            subTags = tag.FindTags(GEDCOMTagName._FOLDER);
            Assert.AreEqual(0, subTags.Count);
        }
Esempio n. 5
0
        public override void Assign(GDMTag source)
        {
            GDMSourceRecord otherSource = (source as GDMSourceRecord);

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

            base.Assign(otherSource);

            fData.Assign(otherSource.fData);
            fOriginator.Assign(otherSource.fOriginator);
            fPublication.Assign(otherSource.fPublication);
            fShortTitle = otherSource.fShortTitle;
            fText.Assign(otherSource.fText);
            fTitle.Assign(otherSource.fTitle);
            AssignList(otherSource.fRepositoryCitations, fRepositoryCitations);
        }
Esempio n. 6
0
        public override void Assign(GDMTag source)
        {
            GDMRecordWithEvents sourceRec = source as GDMRecordWithEvents;

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

            base.Assign(source);

            foreach (GDMCustomEvent sourceEvent in sourceRec.fEvents)
            {
                GDMCustomEvent copy = (GDMCustomEvent)Activator.CreateInstance(sourceEvent.GetType(), new object[] { this });
                copy.Assign(sourceEvent);
                AddEvent(copy);
            }

            fRestriction = sourceRec.Restriction;
        }
Esempio n. 7
0
        public override void Assign(GDMTag source)
        {
            GDMPersonalName otherName = (source as GDMPersonalName);

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

            base.Assign(otherName);

            fFirstPart = otherName.fFirstPart;
            fSurname   = otherName.fSurname;
            fLastPart  = otherName.fLastPart;

            fLanguage = otherName.fLanguage;
            fNameType = otherName.fNameType;

            fPieces.Assign(otherName.Pieces);
        }
Esempio n. 8
0
        public override void Assign(GDMTag source)
        {
            GDMIndividualRecord sourceRec = source as GDMIndividualRecord;

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

            base.Assign(source);

            fSex = sourceRec.fSex;

            foreach (GDMPersonalName srcName in sourceRec.fPersonalNames)
            {
                GDMPersonalName copyName = new GDMPersonalName(this);
                copyName.Assign(srcName);
                AddPersonalName(copyName);
            }
        }
Esempio n. 9
0
        public override void Assign(GDMTag source)
        {
            GDMCustomEvent sourceObj = (source as GDMCustomEvent);

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

            base.Assign(sourceObj);

            fAddress.Assign(sourceObj.fAddress);
            fAgency         = sourceObj.fAgency;
            fCause          = sourceObj.fCause;
            fClassification = sourceObj.fClassification;
            fDate.Assign(sourceObj.fDate);
            fPlace.Assign(sourceObj.fPlace);
            fReligiousAffilation = sourceObj.fReligiousAffilation;
            fRestriction         = sourceObj.fRestriction;
        }
Esempio n. 10
0
        public virtual void MoveTo(GDMRecord targetRecord)
        {
            var subTags = SubTags;

            while (subTags.Count > 0)
            {
                GDMTag tag = subTags.Extract(0);
                if (tag.GetTagType() == GEDCOMTagType.CHAN)
                {
                    tag.Dispose();
                }
                else
                {
                    targetRecord.AddTag(tag);
                }
            }

            while (fNotes.Count > 0)
            {
                GDMTag tag = fNotes.Extract(0);
                targetRecord.Notes.Add((GDMNotes)tag);
            }

            while (fMultimediaLinks.Count > 0)
            {
                GDMTag tag = fMultimediaLinks.Extract(0);
                targetRecord.MultimediaLinks.Add((GDMMultimediaLink)tag);
            }

            while (fSourceCitations.Count > 0)
            {
                GDMTag tag = fSourceCitations.Extract(0);
                targetRecord.SourceCitations.Add((GDMSourceCitation)tag);
            }

            while (fUserReferences.Count > 0)
            {
                GDMTag tag = fUserReferences.Extract(0);
                targetRecord.UserReferences.Add((GDMUserReference)tag);
            }
        }
Esempio n. 11
0
        public override float IsMatch(GDMTag tag, MatchParams matchParams)
        {
            if (tag == null)
            {
                return(0.0f);
            }
            GDMCustomEvent ev = (GDMCustomEvent)tag;

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

            GDMDateValue dtVal  = this.Date;
            GDMDateValue 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.HasPlace && !ev.HasPlace)
                {
                    locMatch = 100.0f;
                }
                else if (this.HasPlace && ev.HasPlace && this.Place.StringValue == ev.Place.StringValue)
                {
                    locMatch = 100.0f;
                }
            }

            float match = (dateMatch + locMatch) / matches;

            return(match);
        }
Esempio n. 12
0
        public IList <GDMTag> FindTags(string tagName)
        {
            if (fTags == null)
            {
                return(null);
            }

            IList <GDMTag> result = new List <GDMTag>();

            GDMTag tag = FindTag(tagName, 0);

            while (tag != null)
            {
                int idx = fTags.IndexOf(tag);
                result.Add(tag);

                tag = FindTag(tagName, idx + 1);
            }

            return(result);
        }
Esempio n. 13
0
        public override void Assign(GDMTag source)
        {
            GDMRecordWithEvents sourceRec = source as GDMRecordWithEvents;

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

            base.Assign(source);

            for (int i = 0, count = sourceRec.fEvents.Count; i < count; i++)
            {
                GDMCustomEvent sourceEvent = sourceRec.fEvents[i];
                GDMCustomEvent copy        = (GDMCustomEvent)Activator.CreateInstance(sourceEvent.GetType());
                copy.Assign(sourceEvent);
                AddEvent(copy);
            }

            fRestriction = sourceRec.Restriction;
        }
Esempio n. 14
0
        public void Test_Common()
        {
            using (GDMSourceData data = new GDMSourceData(null)) {
                Assert.IsNotNull(data);

                data.Agency = "test agency";
                Assert.AreEqual("test agency", data.Agency);

                GDMTag evenTag = data.Events.Add(new GDMSourceEvent(data));
                Assert.IsNotNull(evenTag);

                GDMSourceEvent evt = data.Events[0];
                Assert.AreEqual(evenTag, evt);

                data.ReplaceXRefs(new GDMXRefReplacer());

                Assert.IsFalse(data.IsEmpty());
                data.Clear();
                Assert.IsTrue(data.IsEmpty());
            }
        }
Esempio n. 15
0
        public void Test_Common()
        {
            GDMTag obj1 = new GDMTag();
            GDMTag obj2 = new GDMTag();

            using (var list = new GDMList <GDMTag>()) {
                // internal list is null (all routines instant returned)
                list.Delete(null);
                list.Exchange(0, 1);
                Assert.IsNull(list.Extract(0));
                Assert.IsNull(list.Extract(null));

                // normal checks
                list.Add(obj1);
                list.Add(obj2);
                Assert.AreEqual(0, list.IndexOf(obj1));
                Assert.AreEqual(1, list.IndexOf(obj2));

                using (var list2 = new GDMList <GDMTag>()) {
                    list2.AddRange(list);
                    Assert.AreEqual(2, list2.Count);
                }

                list.Delete(obj1);
                Assert.AreEqual(-1, list.IndexOf(obj1));
                Assert.AreEqual(0, list.IndexOf(obj2));

                list.Add(obj1);
                Assert.AreEqual(1, list.IndexOf(obj1));
                Assert.AreEqual(0, list.IndexOf(obj2));
                list.Exchange(0, 1);
                Assert.AreEqual(0, list.IndexOf(obj1));
                Assert.AreEqual(1, list.IndexOf(obj2));

                Assert.AreEqual(null, list.Extract(null));
                list.Add(obj1);
                Assert.AreEqual(obj1, list.Extract(obj1));
            }
        }
Esempio n. 16
0
        public override void Assign(GDMTag source)
        {
            GDMResearchRecord sourceObj = (source as GDMResearchRecord);

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

            base.Assign(sourceObj);

            fResearchName = sourceObj.fResearchName;
            fPriority     = sourceObj.fPriority;
            fStatus       = sourceObj.fStatus;
            fStartDate.Assign(sourceObj.fStartDate);
            fStopDate.Assign(sourceObj.fStopDate);
            fPercent = sourceObj.fPercent;

            AssignList(sourceObj.fTasks, fTasks);
            AssignList(sourceObj.fCommunications, fCommunications);
            AssignList(sourceObj.fGroups, fGroups);
        }
Esempio n. 17
0
        public override void Assign(GDMTag source)
        {
            GDMPersonalNamePieces otherPNP = (source as GDMPersonalNamePieces);

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

            base.Assign(otherPNP);

            fPrefix         = otherPNP.fPrefix;
            fGiven          = otherPNP.fGiven;
            fNickname       = otherPNP.fNickname;
            fSurnamePrefix  = otherPNP.fSurnamePrefix;
            fSurname        = otherPNP.fSurname;
            fSuffix         = otherPNP.fSuffix;
            fPatronymicName = otherPNP.fPatronymicName;
            fMarriedName    = otherPNP.fMarriedName;
            fReligiousName  = otherPNP.fReligiousName;
            fCensusName     = otherPNP.fCensusName;
        }
Esempio n. 18
0
        public override void Assign(GDMTag source)
        {
            GDMCustomEvent sourceObj = (source as GDMCustomEvent);

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

            base.Assign(sourceObj);

            if (sourceObj.fAddress != null)
            {
                Address.Assign(sourceObj.fAddress);
            }
            fAgency         = sourceObj.fAgency;
            fCause          = sourceObj.fCause;
            fClassification = sourceObj.fClassification;
            fDate.Assign(sourceObj.fDate);
            if (sourceObj.fPlace != null)
            {
                Place.Assign(sourceObj.fPlace);
            }
            fReligiousAffilation = sourceObj.fReligiousAffilation;
            fRestriction         = sourceObj.fRestriction;
            if (sourceObj.fNotes != null)
            {
                AssignList(sourceObj.fNotes, Notes);
            }
            if (sourceObj.fSourceCitations != null)
            {
                AssignList(sourceObj.fSourceCitations, SourceCitations);
            }
            if (sourceObj.fMultimediaLinks != null)
            {
                AssignList(sourceObj.fMultimediaLinks, MultimediaLinks);
            }
        }
Esempio n. 19
0
        public void Test_Common()
        {
            GDMTag obj1 = new GDMTag(null);
            GDMTag obj2 = new GDMTag(null);

            using (GDMList <GDMTag> list = new GDMList <GDMTag>(null)) {
                // internal list is null (all routines instant returned)
                list.Delete(null);
                list.Exchange(0, 1);
                Assert.IsNull(list.Extract(0));
                Assert.IsNull(list.Extract(null));

                // normal checks
                list.Add(obj1);
                list.Add(obj2);
                Assert.AreEqual(0, list.IndexOf(obj1));
                Assert.AreEqual(1, list.IndexOf(obj2));

                list.Delete(obj1);
                Assert.AreEqual(-1, list.IndexOf(obj1));
                Assert.AreEqual(0, list.IndexOf(obj2));

                list.Add(obj1);
                Assert.AreEqual(1, list.IndexOf(obj1));
                Assert.AreEqual(0, list.IndexOf(obj2));
                list.Exchange(0, 1);
                Assert.AreEqual(0, list.IndexOf(obj1));
                Assert.AreEqual(1, list.IndexOf(obj2));

                Assert.AreEqual(null, list.Extract(null));
                list.Add(obj1);
                Assert.AreEqual(obj1, list.Extract(obj1));

                foreach (GDMObject obj in list)
                {
                }
            }
        }
Esempio n. 20
0
 public GDMTag AddTag(GDMTag tag)
 {
     fTags.Add(tag);
     return(tag);
 }
Esempio n. 21
0
        public override float IsMatch(GDMTag tag, MatchParams matchParams)
        {
            GDMIndividualRecord indi = tag as GDMIndividualRecord;

            if (indi == null)
            {
                return(0.0f);
            }

            if (Sex != indi.Sex)
            {
                return(0.0f);
            }

            bool womanMode = (Sex == GDMSex.svFemale);

            float matchesCount = 0.0f;
            float nameMatch    = 0.0f;
            float birthMatch   = 0.0f;
            float deathMatch   = 0.0f;

            // check name

            /*for (int i = 0; i < indi.PersonalNames.Count; i++)
             *          {
             *                  for (int k = 0; k < fPersonalNames.Count; k++)
             *                  {
             *                          float currentNameMatch = fPersonalNames[k].IsMatch(indi.PersonalNames[i]);
             *                          nameMatch = Math.Max(nameMatch, currentNameMatch);
             *                  }
             *          }*/

            string iName = GetComparableName(womanMode);
            string kName = indi.GetComparableName(womanMode);

            if (!string.IsNullOrEmpty(iName) && !string.IsNullOrEmpty(kName))
            {
                nameMatch = GetStrMatch(iName, kName, matchParams);
                matchesCount++;
            }

            // 0% name match would be pointless checking other details
            if (nameMatch != 0.0f && matchParams.DatesCheck)
            {
                var dates     = GetLifeDates();
                var indiDates = indi.GetLifeDates();

                if (dates.BirthEvent != null && indiDates.BirthEvent != null)
                {
                    birthMatch = dates.BirthEvent.IsMatch(indiDates.BirthEvent, matchParams);
                    matchesCount++;
                }
                else if (dates.BirthEvent == null && indiDates.BirthEvent == null)
                {
                    birthMatch = 100.0f;
                    matchesCount++;
                }
                else
                {
                    matchesCount++;
                }

                /*if (death != null && indiDeath != null) {
                 *                      deathMatch = death.IsMatch(indiDeath, matchParams);
                 *                      matches++;
                 *              } else if (death == null && indiDeath == null) {
                 *                      deathMatch = 100.0f;
                 *                      matches++;
                 *              } else {
                 *                      matches++;
                 *              }*/
            }

            float match = (nameMatch + birthMatch + deathMatch) / matchesCount;

            return(match);
        }
Esempio n. 22
0
 public void Test_IndexOf()
 {
     using (GDMTag tag = new GDMTag(GEDCOMTagsTable.Lookup(""), "")) {
         Assert.AreEqual(-1, tag.SubTags.IndexOf(null));
     }
 }
Esempio n. 23
0
 public GDMTag AddEmailAddress(string value)
 {
     return(fEmailList.Add(GDMTag.Create(this, (int)GEDCOMTagType.EMAIL, value)));
 }
Esempio n. 24
0
 public virtual float IsMatch(GDMTag tag, MatchParams matchParams)
 {
     return(0.0f);
 }
Esempio n. 25
0
 public GDMTag AddFaxNumber(string value)
 {
     return(fFaxList.Add(GDMTag.Create(this, (int)GEDCOMTagType.FAX, value)));
 }
Esempio n. 26
0
 public GDMTag AddPhoneNumber(string value)
 {
     return(fPhoneList.Add(GDMTag.Create(this, (int)GEDCOMTagType.PHON, value)));
 }
Esempio n. 27
0
 public GDMTag AddWebPage(string value)
 {
     return(fWWWList.Add(GDMTag.Create(this, (int)GEDCOMTagType.WWW, value)));
 }