public GDMCustomEvent FindEvent(GEDCOMTagType eventType) { GDMCustomEvent result = null; if (fEvents == null) { return(result); } int evtType = (int)eventType; int num = fEvents.Count; for (int i = 0; i < num; i++) { GDMCustomEvent evt = fEvents[i]; if (evt.Id == evtType) { result = evt; break; } } return(result); }
public static void RegisterTag(GEDCOMTagType tag, string tagName, TagConstructor constructor, AddTagHandler addHandler = null, SaveTagHandler saveHandler = null, bool skipEmpty = false) { GEDCOMTagProps tagProps = RegisterTag(tag, tagName); tagProps.Constructor = constructor; tagProps.AddHandler = addHandler; tagProps.SaveHandler = saveHandler; tagProps.SkipEmpty = skipEmpty; }
public static GEDCOMTagProps RegisterTag(GEDCOMTagType tag, string tagName, bool skipEmpty = false) { GEDCOMTagProps tagProps; if (!fDictionary.TryGetValue(tagName, out tagProps)) { int tagId = (int)tag; tagProps = new GEDCOMTagProps(tagId, tagName, skipEmpty); fDictionary.Add(tagName, tagProps); fList[tagId] = tagProps; } return(tagProps); }
public static GEDCOMTagProps RegisterTag(GEDCOMTagType tag, string tagName, TagConstructor constructor = null, AddTagHandler addHandler = null, SaveTagHandler saveHandler = null, bool skipEmpty = false) { GEDCOMTagProps tagProps; if (!fDictionary.TryGetValue(tagName, out tagProps)) { int tagId = (int)tag; tagProps = new GEDCOMTagProps(tagId, tagName, constructor, addHandler, saveHandler, skipEmpty); fDictionary.Add(tagName, tagProps); fList[tagId] = tagProps; } return(tagProps); }
public override void Fetch(GDMRecord aRec) { fRec = (aRec as GDMIndividualRecord); if (fRec == null) { return; } buf_fullname = GKUtils.GetNameString(fRec, true, false); buf_bd = null; buf_dd = null; buf_residence = ""; buf_religion = ""; buf_nationality = ""; buf_education = ""; buf_occupation = ""; buf_caste = ""; buf_mili = ""; buf_mili_ind = ""; buf_mili_dis = ""; buf_mili_rank = ""; buf_title = ""; GlobalOptions gOptions = GlobalOptions.Instance; int num = fRec.Events.Count; for (int i = 0; i < num; i++) { GDMCustomEvent ev = fRec.Events[i]; GEDCOMTagType evtType = ev.GetTagType(); if (evtType == GEDCOMTagType.BIRT && buf_bd == null) { buf_bd = ev; } else if (evtType == GEDCOMTagType.DEAT && buf_dd == null) { buf_dd = ev; } else if (evtType == GEDCOMTagType.RESI && buf_residence == "") { buf_residence = GKUtils.GetPlaceStr(ev, gOptions.PlacesWithAddress); } else if (evtType == GEDCOMTagType.RELI && buf_religion == "") { buf_religion = ev.StringValue; } else if (evtType == GEDCOMTagType.NATI && buf_nationality == "") { buf_nationality = ev.StringValue; } else if (evtType == GEDCOMTagType.EDUC && buf_education == "") { buf_education = ev.StringValue; } else if (evtType == GEDCOMTagType.OCCU && buf_occupation == "") { buf_occupation = ev.StringValue; } else if (evtType == GEDCOMTagType.CAST && buf_caste == "") { buf_caste = ev.StringValue; } else if (evtType == GEDCOMTagType._MILI && buf_mili == "") { buf_mili = ev.StringValue; } else if (evtType == GEDCOMTagType._MILI_IND && buf_mili_ind == "") { buf_mili_ind = ev.StringValue; } else if (evtType == GEDCOMTagType._MILI_DIS && buf_mili_dis == "") { buf_mili_dis = ev.StringValue; } else if (evtType == GEDCOMTagType._MILI_RANK && buf_mili_rank == "") { buf_mili_rank = ev.StringValue; } else if (evtType == GEDCOMTagType.TITL && buf_title == "") { buf_title = ev.StringValue; } } }
protected override void LoadFromReader(Stream fileStream, StreamReader reader, string streamCharset = null) { fTree.State = GDMTreeState.osLoading; try { ProgressEventHandler progressHandler = fTree.OnProgress; long fileSize = fileStream.Length; int progress = 0; GDMIndividualRecord lastIndividual = null; GDMTag lastTag = null; GEDCOMTagType lastTagType = GEDCOMTagType.Unknown; XmlReaderSettings settings = new XmlReaderSettings(); settings.DtdProcessing = DtdProcessing.Ignore; using (XmlReader xr = XmlReader.Create(fileStream, settings)) { while (xr.Read()) { if (xr.NodeType == XmlNodeType.Element && !xr.IsEmptyElement) { if (xr.Name == "Person") { lastIndividual = fTree.CreateIndividual(); var persName = new GDMPersonalName(lastIndividual); lastIndividual.AddPersonalName(persName); lastIndividual.UID = xr.GetAttribute("Id"); } else if (xr.Name == "Gender") { lastTagType = GEDCOMTagType.SEX; lastTag = null; } else if (xr.Name == "FirstName") { lastTagType = GEDCOMTagType.GIVN; lastTag = null; } else if (xr.Name == "LastName") { lastTagType = GEDCOMTagType.SURN; lastTag = null; } } else if (xr.NodeType == XmlNodeType.Text) { string nodeValue = xr.Value; if (lastTag != null) { lastTag = null; } else { switch (lastTagType) { case GEDCOMTagType.SEX: if (nodeValue == "Male") { lastIndividual.Sex = GDMSex.svMale; } else if (nodeValue == "Female") { lastIndividual.Sex = GDMSex.svFemale; } break; case GEDCOMTagType.GIVN: lastIndividual.PersonalNames[0].FirstPart = nodeValue; break; case GEDCOMTagType.SURN: lastIndividual.PersonalNames[0].Surname = nodeValue; break; } lastTagType = GEDCOMTagType.Unknown; } } if (progressHandler != null) { int newProgress = (int)Math.Min(100, (fileStream.Position * 100.0f) / fileSize); if (progress != newProgress) { progress = newProgress; progressHandler(fTree, progress); } } } } } finally { fTree.State = GDMTreeState.osReady; } }
public void SetName(GEDCOMTagType tag) { SetName((int)tag); }