private void ReadNameRecord() { GedcomName name; name = _ParseState.Records.Peek() as GedcomName; if (_level == name.ParsingLevel + 1) { switch (_tag) { case "TYPE": if (_lineValueType == GedcomLineValueType.DataType) { name.Type = _lineValue; } break; case "FONE": if (_lineValueType == GedcomLineValueType.DataType) { GedcomVariation variation = new GedcomVariation(); variation.Database = Database; variation.Value = _lineValue; name.PhoneticVariations.Add(variation); } break; case "ROMN": if (_lineValueType == GedcomLineValueType.DataType) { GedcomVariation variation = new GedcomVariation(); variation.Database = Database; variation.Value = _lineValue; name.RomanizedVariations.Add(variation); } break; case "NPFX": if (_lineValueType == GedcomLineValueType.DataType) { // Prefix from NAME has priority if (string.IsNullOrEmpty(name.Prefix)) { name.Prefix = _lineValue; } } break; case "GIVN": if (_lineValueType == GedcomLineValueType.DataType) { // Given from NAME has priority if (string.IsNullOrEmpty(name.Given)) { name.Given = _lineValue; } } break; case "NICK": if (_lineValueType == GedcomLineValueType.DataType) { name.Nick = _lineValue; } break; case "SPFX": if (_lineValueType == GedcomLineValueType.DataType) { // surname prefix from NAME has priority if (string.IsNullOrEmpty(name.SurnamePrefix)) { name.SurnamePrefix = _lineValue; } } break; case "SURN": if (_lineValueType == GedcomLineValueType.DataType) { // surname from NAME has priority if (string.IsNullOrEmpty(name.Given)) { name.Surname = _lineValue; } } break; case "NSFX": if (_lineValueType == GedcomLineValueType.DataType) { // suffix from NAME has priority if (string.IsNullOrEmpty(name.Suffix)) { name.Suffix = _lineValue; } } break; case "NOTE": AddNoteRecord(name); break; case "SOUR": AddSourceCitation(name); break; } } else if (_ParseState.PreviousTag != string.Empty && _level == name.ParsingLevel + 2) { if (_tag == "TYPE") { if (_ParseState.PreviousTag == "FONE") { if (_lineValueType == GedcomLineValueType.DataType) { GedcomVariation variation = name.PhoneticVariations[name.PhoneticVariations.Count - 1]; variation.VariationType = _lineValue; } } else if (_ParseState.PreviousTag == "ROMN") { if (_lineValueType == GedcomLineValueType.DataType) { GedcomVariation variation = name.RomanizedVariations[name.RomanizedVariations.Count - 1]; variation.VariationType = _lineValue; } } } } else { // shouldn't be here Debug.WriteLine("Unknown state / tag parsing name node: " + _tag + "\t at level: " + _level); } }
private void ReadPlaceRecord() { GedcomPlace place; place = _ParseState.Records.Peek() as GedcomPlace; if (_level == place.ParsingLevel + 1) { switch (_tag) { case "FORM": if (_lineValueType == GedcomLineValueType.DataType) { place.Form = _lineValue; } break; case "FONE": if (_lineValueType == GedcomLineValueType.DataType) { GedcomVariation variation = new GedcomVariation(); variation.Database = Database; variation.Value = _lineValue; place.PhoneticVariations.Add(variation); } break; case "ROMN": if (_lineValueType == GedcomLineValueType.DataType) { GedcomVariation variation = new GedcomVariation(); variation.Database = Database; variation.Value = _lineValue; place.RomanizedVariations.Add(variation); } break; case "MAP": // map, longitude / latitude stored as child nodes break; case "NOTE": AddNoteRecord(place); break; } } else if (_ParseState.PreviousTag != string.Empty && _level == place.ParsingLevel + 2) { if (_tag == "TYPE") { if (_ParseState.PreviousTag == "FONE") { if (_lineValueType == GedcomLineValueType.DataType) { GedcomVariation variation = place.PhoneticVariations[place.PhoneticVariations.Count - 1]; variation.VariationType = _lineValue; } } else if (_ParseState.PreviousTag == "ROMN") { if (_lineValueType == GedcomLineValueType.DataType) { GedcomVariation variation = place.RomanizedVariations[place.RomanizedVariations.Count - 1]; variation.VariationType = _lineValue; } } } else if (_ParseState.PreviousTag == "MAP") { if (_tag == "LATI") { if (_lineValueType == GedcomLineValueType.DataType) { place.Latitude = _lineValue; } } else if (_tag == "LONG") { if (_lineValueType == GedcomLineValueType.DataType) { place.Longitude = _lineValue; } } } } else { // shouldn't be here Debug.WriteLine("Unknown state / tag parsing place node: " + _tag + "\t at level: " + _level); } }