public override void MoveTo(GDMRecord targetRecord) { GDMRecordWithEvents target = targetRecord as GDMRecordWithEvents; if (target == null) { throw new ArgumentException(@"Argument is null or wrong type", "targetRecord"); } base.MoveTo(targetRecord); while (fEvents.Count > 0) { GDMCustomEvent obj = fEvents.Extract(0); target.AddEvent(obj); } target.Restriction = fRestriction; }
public int IndexOfChild(GDMRecord childRec) { int result = -1; if (childRec == null) { return(result); } for (int i = fChildren.Count - 1; i >= 0; i--) { if (fChildren[i].XRef == childRec.XRef) { result = i; break; } } return(result); }
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); } }
public void SetPtrValue(GDMPointer ptr, GDMRecord record) { if (ptr == null) { return; } ptr.XRef = string.Empty; if (record == null) { return; } string xrf = record.XRef; if (string.IsNullOrEmpty(xrf)) { xrf = NewXRef(record); } ptr.XRef = xrf; }
public override void MoveTo(GDMRecord targetRecord, bool clearDest) { GDMSourceRecord targetSource = targetRecord as GDMSourceRecord; if (targetSource == null) { throw new ArgumentException(@"Argument is null or wrong type", "targetRecord"); } StringList titl = new StringList(); StringList orig = new StringList(); StringList publ = new StringList(); StringList text = new StringList(); try { titl.Text = (targetSource.Title.Lines.Text + "\n" + Title.Lines.Text).Trim(); orig.Text = (targetSource.Originator.Lines.Text + "\n" + Originator.Lines.Text).Trim(); publ.Text = (targetSource.Publication.Lines.Text + "\n" + Publication.Lines.Text).Trim(); text.Text = (targetSource.Text.Lines.Text + "\n" + Text.Lines.Text).Trim(); base.MoveTo(targetRecord, clearDest); targetSource.Title.Lines.Assign(titl); targetSource.Originator.Lines.Assign(orig); targetSource.Publication.Lines.Assign(publ); targetSource.Text.Lines.Assign(text); while (fRepositoryCitations.Count > 0) { GDMRepositoryCitation obj = fRepositoryCitations.Extract(0); obj.ResetOwner(targetSource); targetSource.RepositoryCitations.Add(obj); } } finally { titl.Dispose(); orig.Dispose(); publ.Dispose(); text.Dispose(); } }
public bool DeleteNoteRecord(GDMNoteRecord nRec) { if (nRec == null) { return(false); } int num = fRecords.Count; for (int i = 0; i < num; i++) { GDMRecord rec = fRecords[i]; for (int j = rec.Notes.Count - 1; j >= 0; j--) { if (rec.Notes[j].Value == nRec) { rec.Notes.DeleteAt(j); } } } DeleteRecord(nRec); return(true); }
public bool DeleteMediaRecord(GDMMultimediaRecord mRec) { if (mRec == null) { return(false); } int num = fRecords.Count; for (int i = 0; i < num; i++) { GDMRecord rec = fRecords[i]; for (int j = rec.MultimediaLinks.Count - 1; j >= 0; j--) { if (rec.MultimediaLinks[j].Value == mRec) { rec.MultimediaLinks.DeleteAt(j); } } } DeleteRecord(mRec); return(true); }
public bool DeleteSourceRecord(GDMSourceRecord srcRec) { if (srcRec == null) { return(false); } int num = fRecords.Count; for (int i = 0; i < num; i++) { GDMRecord rec = fRecords[i]; for (int j = rec.SourceCitations.Count - 1; j >= 0; j--) { if (rec.SourceCitations[j].Value == srcRec) { rec.SourceCitations.DeleteAt(j); } } } DeleteRecord(srcRec); return(true); }
public int IndexOf(GDMRecord record) { return(fRecords.IndexOf(record)); }
public void DeleteRecord(GDMRecord record) { XRefIndex_DeleteRecord(record); fRecords.Delete(record); }
public GDMRecord AddRecord(GDMRecord record) { fRecords.Add(record); XRefIndex_AddRecord(record); return(record); }
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); } }
public XRefEntry(GDMRecord rec, string oldXRef, string newXRef) { Rec = rec; OldXRef = oldXRef; NewXRef = newXRef; }
public void Test_GDMRecord() { GDMRecord obj = new GDMRecord(null); obj.Dispose(); }
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); } }
public void AddXRef(GDMRecord rec, string oldXRef, string newXRef) { fList.Add(new XRefEntry(rec, oldXRef, newXRef)); }
public void Test_Common() { GDMTree tree = new GDMTree(); Assert.IsNotNull(tree); Assert.IsNotNull(tree.GetSubmitter()); // Tests of event handlers tree.OnChange += OnTreeChange; tree.OnChanging += OnTreeChanging; tree.OnProgress += OnTreeProgress; tree.BeginUpdate(); Assert.IsTrue(tree.IsUpdated()); GDMRecord rec; GDMIndividualRecord iRec = tree.CreateIndividual(); Assert.IsNotNull(iRec, "CreateIndividual() != null"); string xref = iRec.XRef; rec = tree.XRefIndex_Find(xref); Assert.IsNotNull(rec); Assert.AreEqual(xref, rec.XRef); string uid = iRec.UID; rec = tree.FindUID(uid); Assert.IsNotNull(rec); Assert.AreEqual(uid, rec.UID); Assert.IsNull(tree.FindUID("")); // GDMFamilyRecord famRec = tree.CreateFamily(); Assert.IsNotNull(famRec, "CreateFamily() != null"); // GDMNoteRecord noteRec = tree.CreateNote(); Assert.IsNotNull(noteRec, "CreateNote() != null"); // GDMRepositoryRecord repRec = tree.CreateRepository(); Assert.IsNotNull(repRec, "CreateRepository() != null"); // GDMSourceRecord srcRec = tree.CreateSource(); Assert.IsNotNull(srcRec, "CreateSource() != null"); // GDMMultimediaRecord mmRec = tree.CreateMultimedia(); Assert.IsNotNull(mmRec, "CreateMultimedia() != null"); // GDMRecord sbmrRec = tree.AddRecord(new GDMSubmitterRecord(tree)); Assert.IsNotNull(sbmrRec, "sbmrRec != null"); tree.NewXRef(sbmrRec); string submXRef = sbmrRec.XRef; // GDMSubmissionRecord submRec = tree.AddRecord(new GDMSubmissionRecord(tree)) as GDMSubmissionRecord; Assert.IsNotNull(submRec, "rec1 != null"); tree.NewXRef(submRec); // GDMGroupRecord groupRec = tree.CreateGroup(); Assert.IsNotNull(groupRec, "CreateGroup() != null"); // GDMTaskRecord taskRec = tree.CreateTask(); Assert.IsNotNull(taskRec, "CreateTask() != null"); // GDMCommunicationRecord commRec = tree.CreateCommunication(); Assert.IsNotNull(commRec, "CreateCommunication() != null"); // GDMResearchRecord resRec = tree.CreateResearch(); Assert.IsNotNull(resRec, "CreateResearch() != null"); // GDMLocationRecord locRec = tree.CreateLocation(); Assert.IsNotNull(locRec, "CreateLocation() != null"); tree.EndUpdate(); Assert.IsFalse(tree.IsUpdated()); tree.OnChange -= OnTreeChange; tree.OnChanging -= OnTreeChanging; tree.OnProgress -= OnTreeProgress; int size = 0; var enum1 = tree.GetEnumerator(GDMRecordType.rtNone); GDMRecord rec1; enum1.Reset(); while (enum1.MoveNext(out rec1)) { size++; } Assert.AreEqual(14, size); for (int i = 0; i < tree.RecordsCount; i++) { GDMRecord rec2 = tree[i]; Assert.IsNotNull(rec2); string xref2 = rec2.XRef; GDMRecord rec3 = tree.XRefIndex_Find(xref2); Assert.IsNotNull(rec3); Assert.AreEqual(rec2, rec3); /*string uid = rec2.UID; * GEDCOMRecord rec4 = tree.FindUID(uid); * Assert.IsNotNull(rec4); * Assert.AreEqual(rec2, rec4);*/ int idx = tree.IndexOf(rec2); Assert.AreEqual(i, idx); } var recordsX = tree.GetRecords <GDMIndividualRecord>(); Assert.IsNotNull(recordsX); Assert.AreEqual(1, recordsX.Count); int[] stats = tree.GetRecordStats(); Assert.IsNotNull(stats); Assert.AreEqual(14, stats.Length); Assert.IsFalse(tree.IsEmpty); Assert.IsFalse(tree.DeleteFamilyRecord(null)); Assert.IsTrue(tree.DeleteFamilyRecord(famRec)); Assert.IsFalse(tree.DeleteNoteRecord(null)); Assert.IsTrue(tree.DeleteNoteRecord(noteRec)); Assert.IsFalse(tree.DeleteSourceRecord(null)); Assert.IsTrue(tree.DeleteSourceRecord(srcRec)); Assert.IsFalse(tree.DeleteGroupRecord(null)); Assert.IsTrue(tree.DeleteGroupRecord(groupRec)); Assert.IsFalse(tree.DeleteLocationRecord(null)); Assert.IsTrue(tree.DeleteLocationRecord(locRec)); Assert.IsFalse(tree.DeleteResearchRecord(null)); Assert.IsTrue(tree.DeleteResearchRecord(resRec)); Assert.IsFalse(tree.DeleteCommunicationRecord(null)); Assert.IsTrue(tree.DeleteCommunicationRecord(commRec)); Assert.IsFalse(tree.DeleteTaskRecord(null)); Assert.IsTrue(tree.DeleteTaskRecord(taskRec)); Assert.IsFalse(tree.DeleteMediaRecord(null)); Assert.IsTrue(tree.DeleteMediaRecord(mmRec)); Assert.IsFalse(tree.DeleteIndividualRecord(null)); Assert.IsTrue(tree.DeleteIndividualRecord(iRec)); Assert.IsFalse(tree.DeleteRepositoryRecord(null)); Assert.IsTrue(tree.DeleteRepositoryRecord(repRec)); tree.Clear(); Assert.AreEqual(0, tree.RecordsCount); Assert.IsTrue(tree.IsEmpty); tree.State = GDMTreeState.osReady; Assert.AreEqual(GDMTreeState.osReady, tree.State); // Tests of GEDCOMTree.Extract() using (GDMTree tree2 = new GDMTree()) { GDMIndividualRecord iRec2 = tree.AddRecord(new GDMIndividualRecord(tree2)) as GDMIndividualRecord; Assert.IsNotNull(iRec2); tree2.NewXRef(iRec2); tree2.AddRecord(iRec2); int rIdx = tree2.IndexOf(iRec2); Assert.IsTrue(rIdx >= 0); GDMRecord extractedRec = tree2.Extract(rIdx); Assert.AreEqual(iRec2, extractedRec); Assert.IsTrue(tree2.IndexOf(iRec2) < 0); } }
public TaskGoalRet(GDMGoalType goalType, string goalXRef, GDMRecord goalRec) { GoalType = goalType; GoalXRef = goalXRef; GoalRec = goalRec; }