예제 #1
0
		protected virtual void Changed()
		{
			if (_database == null)
			{
//				System.Console.WriteLine("Changed() called on record with no database set");
//				
//				System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace();
//				foreach (System.Diagnostics.StackFrame f in trace.GetFrames())
//				{
//					System.Console.WriteLine(f);
//				}
			}
			else if (!_database.Loading)
			{
				if (_ChangeDate == null)
				{
					_ChangeDate = new GedcomChangeDate(_database);
					// FIXME: what level?
				}
				DateTime now = DateTime.Now;
				
				_ChangeDate.Date1 = now.ToString("dd MMM yyyy");
				_ChangeDate.Time = now.ToString("hh:mm:ss");
			}
		}
예제 #2
0
		private void ReadSubmitterRecord()
		{
			GedcomSubmitterRecord submitterRecord;
									
			submitterRecord = _ParseState.Records.Peek() as GedcomSubmitterRecord;

			if (_tag.StartsWith("_"))
			{
				switch (_tag)
				{
					default:
						GedcomCustomRecord custom = new GedcomCustomRecord();
						custom.Level = _level;
						custom.XRefID = _xrefID;
						custom.Tag = _tag;
									
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							custom.Classification = _lineValue;
						}
						
						// FIXME: may want to use customs at some point
		
						_ParseState.Records.Push(custom);
						break;
				}
			}

			if (_level == submitterRecord.ParsingLevel + 1)
			{
				switch (_tag)
				{
					case "NAME":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							submitterRecord.Name = _lineValue;	
						}
						break;
					case "ADDR":
						if (submitterRecord.Address == null)
						{
							submitterRecord.Address = new GedcomAddress();
							submitterRecord.Address.Database = Database;
						}
						
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							submitterRecord.Address.AddressLine = _lineValue;	
						}
						
						break;
					case "PHON":
						if (submitterRecord.Address == null)
						{
							submitterRecord.Address = new GedcomAddress();	
							submitterRecord.Address.Database = Database;
						}
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							if (string.IsNullOrEmpty(submitterRecord.Address.Phone1))
							{
								submitterRecord.Address.Phone1 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(submitterRecord.Address.Phone2))
							{
								submitterRecord.Address.Phone2 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(submitterRecord.Address.Phone3))
							{
								submitterRecord.Address.Phone3 = _lineValue;	
							}
							else
							{
								// should never occur only 3 phone numbers are allowed	
							}
						}
						break;
					case "EMAIL":
						if (submitterRecord.Address == null)
						{
							submitterRecord.Address = new GedcomAddress();	
							submitterRecord.Address.Database = Database;
						}
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							if (string.IsNullOrEmpty(submitterRecord.Address.Email1))
							{
								submitterRecord.Address.Email1 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(submitterRecord.Address.Email2))
							{
								submitterRecord.Address.Email2 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(submitterRecord.Address.Email3))
							{
								submitterRecord.Address.Email3 = _lineValue;	
							}
							else
							{
								// should never occur only 3 emails are allowed	
							}
						}
						break;
					case "FAX":
						if (submitterRecord.Address == null)
						{
							submitterRecord.Address = new GedcomAddress();	
							submitterRecord.Address.Database = Database;
						}
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							if (string.IsNullOrEmpty(submitterRecord.Address.Fax1))
							{
								submitterRecord.Address.Fax1 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(submitterRecord.Address.Fax2))
							{
								submitterRecord.Address.Fax2 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(submitterRecord.Address.Fax3))
							{
								submitterRecord.Address.Fax3 = _lineValue;	
							}
							else
							{
								// should never occur only 3 fax numbers are allowed	
							}
						}
						break;
					case "WWW":
						if (submitterRecord.Address == null)
						{
							submitterRecord.Address = new GedcomAddress();	
							submitterRecord.Address.Database = Database;
						}
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							if (string.IsNullOrEmpty(submitterRecord.Address.Www1))
							{
								submitterRecord.Address.Www1 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(submitterRecord.Address.Www2))
							{
								submitterRecord.Address.Www2 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(submitterRecord.Address.Www3))
							{
								submitterRecord.Address.Www3 = _lineValue;	
							}
							else
							{
								// should never occur only 3 urls are allowed	
							}
						}
						break;
					case "OBJE":
						AddMultimediaRecord(submitterRecord);
						break;
					case "LANG":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							// only 3 lang are allowed
							for (int i = 0; i < 3; i ++)
							{
								if (string.IsNullOrEmpty(submitterRecord.LanguagePreferences[i]))
								{
									submitterRecord.LanguagePreferences[i] = _lineValue;	
								}
							}
						}
						break;
					case "RFN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							submitterRecord.RegisteredRFN = _lineValue;
						}
						break;
					case "RIN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							submitterRecord.AutomatedRecordID = _lineValue;	
						}
						break;
					case "CHAN":
						GedcomChangeDate date = new GedcomChangeDate(Database);
						date.Level = _level;
						_ParseState.Records.Push(date);
						break;
					case "NOTE":
					    AddNoteRecord(submitterRecord);
						break;
				}
			}
			else if ( (!string.IsNullOrEmpty(_ParseState.PreviousTag)) &&
			            _level == submitterRecord.Level + 2) //_ParseState.PreviousLevel + 2)
			{
				AddressParse(submitterRecord.Address, _tag, _lineValue, _lineValueType);
			}
			else
			{
				// shouldn't be here
				Debug.WriteLine("Unknown state / tag parsing submitter node: " + _tag + "\t at level: " + _level);
			}
		}
예제 #3
0
		private void ReadSubmissionRecord()
		{
			GedcomSubmissionRecord submissionRecord;
			
			submissionRecord = _ParseState.Records.Peek() as GedcomSubmissionRecord;
			
			if (_level == submissionRecord.ParsingLevel + 1)
			{
				switch (_tag)
				{
					case "SUBM":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							submissionRecord.Submitter = _lineValue;
							_missingReferences.Add(_lineValue);
						}
						else
						{
							GedcomSubmitterRecord submitter = new GedcomSubmitterRecord();
							submitter.Level = 0; // new top level submitter, always 0;
							submitter.ParsingLevel = _level;
							submitter.XRefID = Database.GenerateXref("SUBM");
							
							_ParseState.Records.Push(submitter);
							
							submissionRecord.Submitter = submitter.XRefID;
						}
						
						break;
					case "FAMF":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							submissionRecord.FamilyFile = _lineValue;	
						}
						break;
					case "TEMP":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							submissionRecord.TempleCode = _lineValue;	
						}
						break;
					case "ANCE":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							int num = 0;
							if (int.TryParse(_lineValue, out num))
							{
								submissionRecord.GenerationsOfAncestors = num;
							}
						}
						break;
					case "DESC":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							int num = 0;
							if (int.TryParse(_lineValue, out num))
							{
								submissionRecord.GenerationsOfDecendants = num;
							}
						}
						break;
					case "ORDI":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							submissionRecord.OrdinanceProcessFlag = (string.Compare(_lineValue, "YES", true) == 0); 	
						}
						break;
					case "RIN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							submissionRecord.AutomatedRecordID = _lineValue;	
						}
						break;
					case "CHAN":
						GedcomChangeDate date = new GedcomChangeDate(Database);
						date.Level = _level;
						_ParseState.Records.Push(date);
						break;
					case "NOTE":
					    AddNoteRecord(submissionRecord);
						break;
				}
			}
			else
			{
				// shouldn't be here
				Debug.WriteLine("Unknown state / tag parsing submission node: " + _tag + "\t at level: " + _level);
			}
		}
예제 #4
0
		private void ReadSourceRecord()
		{
			GedcomSourceRecord sourceRecord;
									
			sourceRecord = _ParseState.Records.Peek() as GedcomSourceRecord;
			
			if (_level == sourceRecord.ParsingLevel + 1)
			{

				// hack, at this level won't have CONT/CONC so end any building we
				// are doing
				if (sourceRecord.TitleText != null)
				{
					sourceRecord.Title = sourceRecord.TitleText.ToString();
					sourceRecord.TitleText = null;
				}
				else if (sourceRecord.OriginatorText != null)
				{
					sourceRecord.Originator = sourceRecord.OriginatorText.ToString();
					sourceRecord.OriginatorText = null;
				}
				else if (sourceRecord.PublicationText != null)
				{
					sourceRecord.PublicationFacts = sourceRecord.PublicationText.ToString();
					sourceRecord.PublicationText = null;
				}
				else if (sourceRecord.TextText != null)
				{
					sourceRecord.Text = sourceRecord.TextText.ToString();
					sourceRecord.TextText = null;
				}
			
				switch (_tag)
				{
					case "DATA":
						// info held in child nodes
						break;
					case "AUTH":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.OriginatorText = new StringBuilder(_lineValue);
						}
						break;
					case "TITL":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.TitleText = new StringBuilder(_lineValue);
						}
						break;
					case "ABBR":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.FiledBy = _lineValue;
						}
						break;
					case "PUBL":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.PublicationText = new StringBuilder(_lineValue);
						}
						break;
					case "TEXT":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							int capacity = _lineValue.Length;
							if (!string.IsNullOrEmpty(sourceRecord.Text))
							{
								capacity += sourceRecord.Text.Length;
								capacity += Environment.NewLine.Length;
							}
							
							sourceRecord.TextText = new StringBuilder(capacity);
							
							if (string.IsNullOrEmpty(sourceRecord.Text))
							{
								sourceRecord.TextText.Append(_lineValue);
							}
							else
							{
								sourceRecord.TextText.Append(sourceRecord.Text);
								sourceRecord.TextText.Append(Environment.NewLine);
								sourceRecord.TextText.Append(_lineValue);	
							}
						}
						break;
					case "REPO":
						GedcomRepositoryCitation citation = new GedcomRepositoryCitation();
						citation.Level = _level;
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							citation.Repository = _lineValue;
							_missingReferences.Add(_lineValue);
						}
						sourceRecord.RepositoryCitations.Add(citation);
					
						_ParseState.Records.Push(citation);
						break;
					case "REFN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.UserReferenceNumber = _lineValue;
						}
						break;
					case "RIN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.AutomatedRecordID = _lineValue;	
						}
						break;
					case "CHAN":
						GedcomChangeDate date = new GedcomChangeDate(Database);
						date.Level = _level;
						_ParseState.Records.Push(date);
						break;
					case "NOTE":
					    AddNoteRecord(sourceRecord);
						break;
					case "OBJE":
						AddMultimediaRecord(sourceRecord);
						break;

				}
			}
			else if ( (!string.IsNullOrEmpty(_ParseState.PreviousTag)) &&
			            _level == sourceRecord.Level + 2) // _ParseState.PreviousLevel + 2)
			{
				if (_ParseState.PreviousTag == "REFN" && _tag == "TYPE")
				{
					if (_lineValueType == GedcomLineValueType.DataType)
					{
						sourceRecord.UserReferenceType = _lineValue;	
					}
				}
				else if (sourceRecord.OriginatorText != null) // (_ParseState.PreviousTag == "AUTH")
				{
					switch (_tag)
					{
						case "CONT":
							sourceRecord.OriginatorText.Append(Environment.NewLine);
							sourceRecord.OriginatorText.Append(_lineValue);
							break;
						case "CONC":
							sourceRecord.OriginatorText.Append(_lineValue);
							break;
					}
				}
				else if (sourceRecord.TitleText != null) // (_ParseState.PreviousTag == "TITL")
				{
					switch (_tag)
					{
						case "CONT":
							sourceRecord.TitleText.Append(Environment.NewLine);
							sourceRecord.TitleText.Append(_lineValue);
							break;
						case "CONC":
							sourceRecord.TitleText.Append(_lineValue);
							break;
					}
				}
				else if (sourceRecord.PublicationText != null) // (_ParseState.PreviousTag == "PUBL")
				{
					switch (_tag)
					{
						case "CONT":
							sourceRecord.PublicationText.Append(Environment.NewLine);
							sourceRecord.PublicationText.Append(_lineValue);
							break;
						case "CONC":
							sourceRecord.PublicationText.Append(_lineValue);
							break;
					}
				}
				else if (sourceRecord.TextText != null) //(_ParseState.PreviousTag == "TEXT")
				{
					switch (_tag)
					{
						case "CONT":
							sourceRecord.TextText.Append(Environment.NewLine);
							sourceRecord.TextText.Append(_lineValue);
							break;
						case "CONC":
							sourceRecord.TextText.Append(_lineValue);
							break;
					}
				}
				else //if (_ParseState.PreviousTag == "DATA")
				{
					switch (_tag)
					{
						case "AGNC":
							if (_lineValueType == GedcomLineValueType.DataType)
							{
								sourceRecord.Agency = _lineValue;	
							}
							break;
						case "EVEN":
							if (_lineValueType == GedcomLineValueType.DataType)
							{
								GedcomRecordedEvent recordedEvent = new GedcomRecordedEvent();
								
								sourceRecord.EventsRecorded.Add(recordedEvent);
								
								string[] events = _lineValue.Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries);
								foreach (string e in events)
								{
									string ev = e.Trim();
									GedcomEvent.GedcomEventType eventType;
									
									if (ev == "EVEN")
									{
										eventType = GedcomEvent.GedcomEventType.GenericEvent;
										recordedEvent.Types.Add(eventType);
									}
									else if (ev == "FACT")
									{
										eventType = GedcomEvent.GedcomEventType.GenericFact;
										recordedEvent.Types.Add(eventType);
									}
									else
									{
										try
										{
											eventType = EnumHelper.Parse<GedcomEvent.GedcomEventType>(ev,true);
											recordedEvent.Types.Add(eventType);	
										}
										catch
										{
											try
											{
												eventType = EnumHelper.Parse<GedcomEvent.GedcomEventType>(ev + "Fact",true);
												recordedEvent.Types.Add(eventType);
											}
											catch
											{
												// FIXME: shouldn't lose data like this
											}
										}
									}									
								}
							}
							break;
						case "NOTE":
						    string xref = AddNoteRecord(sourceRecord);
						    // belongs in data records, not top level record notes
						    sourceRecord.Notes.Remove(xref);
						    sourceRecord.DataNotes.Add(xref);
							break;
					}
				}
			}
			else if ( (!string.IsNullOrEmpty(_ParseState.PreviousTag)) &&
			            _level == sourceRecord.Level + 3) //_ParseState.PreviousLevel + 3)
			{
//				if (_ParseState.PreviousTag == "EVEN")
//				{
					GedcomRecordedEvent recordedEvent = sourceRecord.EventsRecorded[sourceRecord.EventsRecorded.Count - 1];
					switch (_tag)
					{
						case "DATE":
							GedcomDate date = new GedcomDate(Database);
							date.Level = _level;
							_ParseState.Records.Push(date);
							recordedEvent.Date = date;
							_level ++;
							ReadDateRecord();
							_level --;
							_ParseState.Records.Pop();
							break;
						case "PLAC":
							GedcomPlace place = new GedcomPlace();
							place.Level = _level;
						
							recordedEvent.Place = place; 
														
							if (_lineValueType == GedcomLineValueType.DataType)
							{
								place.Name = Database.PlaceNameCollection[_lineValue];
							}
							else
							{
								// invalid, provide a name anyway
								place.Name = "Unknown";
								Debug.WriteLine("invalid place node, no name at level: " + _level);
							}
							_ParseState.Records.Push(place);
							break;
					}
//				}
			}
			else
			{
				// shouldn't be here
				Debug.WriteLine("Unknown state / tag parsing note node: " + _tag + "\t at level: " + _level);
			}
		}
예제 #5
0
		private void ReadNoteRecord()
		{
			GedcomNoteRecord noteRecord;
									
			noteRecord = _ParseState.Records.Peek() as GedcomNoteRecord;
			
			if (_level == noteRecord.ParsingLevel + 1)
			{
				switch (_tag)
				{
					case "CONT":
						noteRecord.ParsedText.Append(Environment.NewLine);
						noteRecord.ParsedText.Append(_lineValue);
						break;
					case "CONC":
						noteRecord.ParsedText.Append(_lineValue);
						break;
					case "REFN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							noteRecord.UserReferenceNumber = _lineValue;
						}
						break;
					case "RIN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							noteRecord.AutomatedRecordID = _lineValue;	
						}
						break;
					case "CHAN":
						GedcomChangeDate date = new GedcomChangeDate(Database);
						date.Level = _level;
						_ParseState.Records.Push(date);
						break;
					case "SOUR":
					    AddSourceCitation(noteRecord);
						break;
				}
			}
			else if ( (!string.IsNullOrEmpty(_ParseState.PreviousTag)) &&
			            _ParseState.PreviousTag == "REFN" &&
			            _level == _ParseState.PreviousLevel + 1)
			{
				if (_tag == "TYPE")
				{
					if (_lineValueType == GedcomLineValueType.DataType)
					{
						noteRecord.UserReferenceType = _lineValue;	
					}
				}
			}
			else
			{
				// shouldn't be here
				Debug.WriteLine("Unknown state / tag parsing note node: " + _tag + "\t at level: " + _level);
			}
		}
예제 #6
0
		private void ReadMultimediaRecord()
		{
			GedcomMultimediaRecord multimediaRecord;
			
			multimediaRecord = _ParseState.Records.Peek() as GedcomMultimediaRecord;
				
			if (_level == multimediaRecord.ParsingLevel + 1)
			{
				switch (_tag)
				{
					case "FORM":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							GedcomMultimediaFile file;
							if (multimediaRecord.Files.Count > 0)
							{
								file = multimediaRecord.Files[multimediaRecord.Files.Count - 1];
							}
							else
							{
								file = new GedcomMultimediaFile();
								file.Database = Database;
								multimediaRecord.Files.Add(file);
							}
							file.Format = _lineValue;
						}
						break;
					case "TITL":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							multimediaRecord.Title = _lineValue;
						}
						break;
						
				
					case "FILE":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							GedcomMultimediaFile file = null;
							if (multimediaRecord.Files.Count > 0)
							{
								file = multimediaRecord.Files[multimediaRecord.Files.Count - 1];
								if (!string.IsNullOrEmpty(file.Filename))
								{
									file = null;
								}
							}
							if (file == null)
							{
								file = new GedcomMultimediaFile();
								file.Database = Database;
								multimediaRecord.Files.Add(file);
							}
							
							file.Filename = _lineValue;
						}
						break;
					case "REFN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							multimediaRecord.UserReferenceNumber = _lineValue;
						}
						break;
					case "RIN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							multimediaRecord.AutomatedRecordID = _lineValue;	
						}
						break;
					case "CHAN":
						GedcomChangeDate date = new GedcomChangeDate(Database);
						date.Level = _level;
						_ParseState.Records.Push(date);
						break;
					case "NOTE":
					    AddNoteRecord(multimediaRecord);
						break;
					case "SOUR":
					    AddSourceCitation(multimediaRecord);				
						break;
				}
			}
			else if (_ParseState.PreviousTag != string.Empty)
			{
				if (_level == multimediaRecord.ParsingLevel + 2)
				{
					if (_ParseState.PreviousTag == "REFN" && _tag == "TYPE")
					{
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							multimediaRecord.UserReferenceType = _lineValue;	
						}
					}
					else if (_ParseState.PreviousTag == "FILE")
					{
						switch (_tag)
						{
							case "FORM":
								if (_lineValueType == GedcomLineValueType.DataType)
								{
									multimediaRecord.Files[multimediaRecord.Files.Count - 1].Format = _lineValue;	
								}
								break;
						}
					}
					else if (_ParseState.PreviousTag == "FORM")
					{
						if (_tag == "MEDI" &&
						    _lineValueType == GedcomLineValueType.DataType)
						{
							// FIXME: GedcomMultiMediaFile should use the enum?
							multimediaRecord.Files[multimediaRecord.Files.Count - 1].SourceMediaType  = _lineValue;
						}
					}
				}
				else if (_level == multimediaRecord.ParsingLevel + 3)
				{
					if (_ParseState.PreviousTag == "FILE" && _tag == "TYPE")
					{
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							// FIXME: GedcomMultiMediaFile should use the enum?
							multimediaRecord.Files[multimediaRecord.Files.Count - 1].SourceMediaType = _lineValue;	
						}
					}
				}
			}
			else
			{
				// shouldn't be here
				Debug.WriteLine("Unknown state / tag parsing multimedia node: " + _tag + "\t at level: " + _level);
			}
		}
예제 #7
0
		private void ReadIndividualRecord()
		{
			GedcomIndividualRecord individualRecord;
			
			individualRecord = _ParseState.Records.Peek() as GedcomIndividualRecord;
			
			GedcomIndividualEvent individualEvent;

			// some custom tags we convert to generic facts/events
			// this means we have to set the line value to the type
			// they represent, so store the real line value and use
			// for the event classification.
			string customToGenericClassification = string.Empty;
			
			if (_tag.StartsWith("_"))
			{
				switch (_tag)
				{
					// we convert _MILT to EVEN Military Service
					case "_MILT":
						_tag = "EVEN";
						_lineValue = "Military Service";
						_lineValueType = GedcomLineValueType.DataType;
						break;
					// we convert _MDCL to FACT Medical
					case "_MDCL":
						_tag = "FACT";
						customToGenericClassification = _lineValue;
						_lineValue = "Medical";
						_lineValueType = GedcomLineValueType.DataType;
						break;
					// we convert _HEIG to FACT Height
					case "_HEIG":
						_tag = "FACT";
						customToGenericClassification = _lineValue;
						_lineValue = "Height";
						_lineValueType = GedcomLineValueType.DataType;
						break;
					// we convert _WEIG to FACT Weight
					case "_WEIG":
						_tag = "FACT";
						customToGenericClassification = _lineValue;
						_lineValue = "Weight";
						_lineValueType = GedcomLineValueType.DataType;
						break;
					default:
						GedcomCustomRecord custom = new GedcomCustomRecord();
						custom.Level = _level;
						custom.XRefID = _xrefID;
						custom.Tag = _tag;
									
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							custom.Classification = _lineValue;
						}
						
						// FIXME: may want to use customs at some point
						//individualRecord.Events.Add(custom);
		
						_ParseState.Records.Push(custom);
						break;
				}
			}
			if (_level == individualRecord.ParsingLevel + 1)
			{
				switch (_tag)
				{
					case "FAMC":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							GedcomFamilyLink childIn = new GedcomFamilyLink();
							childIn.Level = _level;
							childIn.Family = _lineValue;
							childIn.Indi = individualRecord.XRefID;
							
							_missingReferences.Add(_lineValue);
							
							individualRecord.ChildIn.Add(childIn);
							_ParseState.Records.Push(childIn);
							
						}
						break;
					case "FAMS":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							GedcomFamilyLink spouseIn = new GedcomFamilyLink();
							spouseIn.Level = _level;
							spouseIn.Family = _lineValue;
							spouseIn.Indi = individualRecord.XRefID;
							spouseIn.PreferedSpouse = (individualRecord.SpouseIn.Count == 0);
							
							_missingReferences.Add(_lineValue);
							
							individualRecord.SpouseIn.Add(spouseIn);
							_ParseState.Records.Push(spouseIn);
						}
						break;
					case "ASSO":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							GedcomAssociation association = new GedcomAssociation();
							association.Level = _level;
							association.Individual = _lineValue;
							
							_missingReferences.Add(_lineValue);
							
							individualRecord.Associations.Add(association);
							_ParseState.Records.Push(association);
						}
						break;
					case "RESN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							try
							{
								individualRecord.RestrictionNotice = EnumHelper.Parse<GedcomRestrictionNotice>(_lineValue,true);
							}
							catch
							{
								Debug.WriteLine("Invalid restriction type: " + _lineValue);
								
								// default to confidential to protect privacy
								individualRecord.RestrictionNotice = GedcomRestrictionNotice.Confidential;
							}
						}
						break;
					case "NAME":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							GedcomName name = new GedcomName();
							name.Database = _ParseState.Database;
							name.Level = _level;
							name.Name = _lineValue;
							name.PreferedName = (individualRecord.Names.Count == 0);

							individualRecord.Names.Add(name);
							_ParseState.Records.Push(name);
						}
						break;
					// Invalid, but seen from Family Origins, Family Tree Maker, Personal Ancestral File, and Legacy
					case "AKA":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							GedcomName name = new GedcomName();
							name.Database = _ParseState.Database;
							name.Level = _level;
							name.Name = _lineValue;
							name.Type = "aka";
							name.PreferedName = (individualRecord.Names.Count == 0);
							individualRecord.Names.Add(name);
						}
						break;
					case "SEX":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							switch (_lineValue)
							{
								case "M":
									individualRecord.Sex = GedcomSex.Male;
									break;
								case "F":
									individualRecord.Sex = GedcomSex.Female;
									break;
								// non standard
								case "B":
									individualRecord.Sex = GedcomSex.Both;
									break;
								// non standard
								case "N":
									individualRecord.Sex = GedcomSex.Neuter;
									break;
								// non standard
								case "U":
									individualRecord.Sex = GedcomSex.Undetermined;
									break;
							}
						}
						break;
					case "SUBM":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							individualRecord.SubmitterRecords.Add(_lineValue);
							_missingReferences.Add(_lineValue);
						}
						else
						{
							GedcomSubmitterRecord submitter = new GedcomSubmitterRecord();
							submitter.Level = 0; // new top level submitter, always 0
							submitter.ParsingLevel = _level;
							submitter.XRefID = Database.GenerateXref("SUBM");
							
							_ParseState.Records.Push(submitter);
							
							individualRecord.SubmitterRecords.Add(submitter.XRefID);
						}
						break;
					case "ALIA":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							individualRecord.Alia.Add(_lineValue);	
							_missingReferences.Add(_lineValue);
						}
						else if (_lineValueType == GedcomLineValueType.DataType)
						{
							// Family Tree Maker doing this?
							// ALIA is unsupported in gedcom 5.5 as a way of
							// adding multiple names, the spec
							// does say it should be a pointer to an individual
							// though, not another name.
							// spec allows multiple NAME though, so add one
							// with this name
							GedcomName name = new GedcomName();
							name.Database = _ParseState.Database;
							name.Level = _level;
							name.Name = _lineValue;
							name.Type = "aka";
							name.PreferedName = (individualRecord.Names.Count == 0);
							individualRecord.Names.Add(name);
						}
						break;
					case "ANCI":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							individualRecord.Anci.Add(_lineValue);	
							_missingReferences.Add(_lineValue);
						}
						break;
					case "DESI":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							individualRecord.Desi.Add(_lineValue);	
							_missingReferences.Add(_lineValue);
						}
						break;
					case "RFN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualRecord.PermanentRecordFileNumber = _lineValue;	
						}
						break;
					case "AFN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualRecord.AncestralFileNumber = _lineValue;	
						}
						break;
					case "REFN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualRecord.UserReferenceNumber = _lineValue;
						}
						break;
					case "RIN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualRecord.AutomatedRecordID = _lineValue;
						}
						break;
					case "CHAN":
						GedcomChangeDate date = new GedcomChangeDate(Database);
						date.Level = _level;
						_ParseState.Records.Push(date);
						break;
					case "NOTE":
					    AddNoteRecord(individualRecord);
						break;
					case "SOUR":
					    AddSourceCitation(individualRecord);
						break;
					case "OBJE":
						AddMultimediaRecord(individualRecord);
						break;
					case "BIRT":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.BIRT;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "CHR":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.CHR;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "DEAT":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.DEAT;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "BURI":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.BURI;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "CREM":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.CREM;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "ADOP":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.ADOP;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "BAPM":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.BAPM;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "BARM":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.BARM;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "BASM":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.BASM;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "BLES":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.BLES;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "CHRA":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.CHRA;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "CONF":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.CONF;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "FCOM":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.FCOM;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "ORDN":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.ORDN;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "NATU":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.NATU;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "EMIG":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.EMIG;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "IMMI":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.IMMI;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "CENS":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.CENS;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "PROB":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.PROB;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;	
					case "WILL":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.WILL;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;		
					case "GRAD":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.GRAD;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;		
					case "RETI":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.RETI;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;		
					case "EVEN":
						
						// event
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.GenericEvent;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Events.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "CAST":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.CASTFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "DSCR":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.DSCRFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;	
					case "EDUC":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.EDUCFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;					
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;		
					case "IDNO":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.IDNOFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;		
					case "NATI":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.NATIFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;		
					case "NCHI":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.NCHIFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;		
					case "NMR":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.NMRFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;		
					case "OCCU":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.OCCUFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;		
					case "PROP":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.PROPFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;		
					case "RELI":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.RELIFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "RESI":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.RESIFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;	
					case "SSN":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.SSNFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;		
					case "TITL":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.TITLFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;
						}
					
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
					case "FACT":
						
						// fact
						individualEvent = new GedcomIndividualEvent();
						individualEvent.EventType = GedcomEvent.GedcomEventType.GenericFact;
						individualEvent.Level = _level;
						individualEvent.IndiRecord = individualRecord;
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualEvent.EventName = _lineValue;						
						}
						if (!string.IsNullOrEmpty(customToGenericClassification))
						{
							individualEvent.Classification = customToGenericClassification;
						}
						individualRecord.Attributes.Add(individualEvent);
					
						_ParseState.Records.Push(individualEvent);
					
						break;
										
					// Not according to the spec, but Family Tree Maker sticks
					// an address under an individual so we will support reading it
					case "ADDR":
						if (individualRecord.Address == null)
						{
							individualRecord.Address = new GedcomAddress();
							individualRecord.Address.Database = Database;
						}
						
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							individualRecord.Address.AddressLine = _lineValue;
						}
						
						break;
					case "PHON":
						if (individualRecord.Address == null)
						{
							individualRecord.Address = new GedcomAddress();	
							individualRecord.Address.Database = Database;
						}
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							if (string.IsNullOrEmpty(individualRecord.Address.Phone1))
							{
								individualRecord.Address.Phone1 = _lineValue;
							}
							else if (string.IsNullOrEmpty(individualRecord.Address.Phone2))
							{
								individualRecord.Address.Phone2 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(individualRecord.Address.Phone3))
							{
								individualRecord.Address.Phone3 = _lineValue;
							}
							else
							{
								// should never occur only 3 phone numbers are allowed	
							}
						}
						break;
					case "EMAIL":
						if (individualRecord.Address == null)
						{
							individualRecord.Address = new GedcomAddress();	
							individualRecord.Address.Database = Database;
						}
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							if (string.IsNullOrEmpty(individualRecord.Address.Email1))
							{
								individualRecord.Address.Email1 = _lineValue;
							}
							else if (string.IsNullOrEmpty(individualRecord.Address.Email2))
							{
								individualRecord.Address.Email2 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(individualRecord.Address.Email3))
							{
								individualRecord.Address.Email3 = _lineValue;	
							}
							else
							{
								// should never occur only 3 emails are allowed	
							}
						}
						break;
					case "FAX":
						if (individualRecord.Address == null)
						{
							individualRecord.Address = new GedcomAddress();	
							individualRecord.Address.Database = Database;
						}
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							if (string.IsNullOrEmpty(individualRecord.Address.Fax1))
							{
								individualRecord.Address.Fax1 = _lineValue;
							}
							else if (string.IsNullOrEmpty(individualRecord.Address.Fax2))
							{
								individualRecord.Address.Fax2 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(individualRecord.Address.Fax3))
							{
								individualRecord.Address.Fax3 = _lineValue;	
							}
							else
							{
								// should never occur only 3 fax numbers are allowed	
							}
						}
						break;
					case "WWW":
						if (individualRecord.Address == null)
						{
							individualRecord.Address = new GedcomAddress();	
							individualRecord.Address.Database = Database;
						}
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							if (string.IsNullOrEmpty(individualRecord.Address.Www1))
							{
								individualRecord.Address.Www1 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(individualRecord.Address.Www2))
							{
								individualRecord.Address.Www2 = _lineValue;	
							}
							else if (string.IsNullOrEmpty(individualRecord.Address.Www3))
							{
								individualRecord.Address.Www3 = _lineValue;	
							}
							else
							{
								// should never occur only 3 urls are allowed	
							}
						}
						break;
				}
			}
			else if ( (!string.IsNullOrEmpty(_ParseState.PreviousTag)) &&
			            _level == _ParseState.PreviousLevel + 1)
			{
				string pTag = _ParseState.PreviousTag;
				
				if (pTag == "REFN" && _tag == "TYPE")
				{
					if (_lineValueType == GedcomLineValueType.DataType)
					{
						individualRecord.UserReferenceType = _lineValue;	
					}
				}
				else
				{
					AddressParse(individualRecord.Address, _tag, _lineValue, _lineValueType);	
				}
			}
			else if ( (!string.IsNullOrEmpty(_ParseState.PreviousTag)) &&
			            _level == _ParseState.PreviousLevel)
			{
				AddressParse(individualRecord.Address, _tag, _lineValue, _lineValueType);
			}
			else
			{
				// shouldn't be here
				Debug.WriteLine("Unknown state / tag parsing individual (" + individualRecord.XRefID + ") node: " + _tag + "\t at level: " + _level);
				System.Console.WriteLine("Unknown state / tag parsing individual (" + individualRecord.XRefID + ") node: " + _tag + "\t at level: " + _level);
				System.Console.WriteLine("Previous tag: " + _ParseState.PreviousTag + "\tPrevious Level: " + _ParseState.PreviousLevel);
			}
		}
예제 #8
0
		private void ReadFamilyRecord()
		{
			GedcomFamilyRecord familyRecord;
			
			// allowed sub records
			GedcomFamilyEvent familyEvent;
						
			familyRecord = _ParseState.Records.Peek() as GedcomFamilyRecord;
			
			if (_tag.StartsWith("_"))
			{
				switch (_tag)
				{
					case "_MSTAT":
						try
						{
							familyRecord.StartStatus = EnumHelper.Parse<MarriageStartStatus>(_lineValue, true);
						}
						catch
						{
							System.Diagnostics.Debug.WriteLine("Unknown marriage start state: " + _lineValue);
						}
						break;
					case "_FREL":
					case "_MREL":
						if ( (!string.IsNullOrEmpty(_ParseState.PreviousTag)) &&
						    _ParseState.PreviousTag == "CHIL" &&
						    _level == _ParseState.PreviousLevel + 1)
						{
							string childID = familyRecord.Children[familyRecord.Children.Count - 1];
							Gedcom.PedegreeLinkageType currentType = familyRecord.GetLinkageType(childID);
							
							Gedcom.GedcomAdoptionType linkTo = Gedcom.GedcomAdoptionType.Husband;
							if (_tag == "_MREL")
							{
								linkTo = Gedcom.GedcomAdoptionType.Wife;
							}
							
							switch (_lineValue)
							{
								case "Natural":
									familyRecord.SetLinkageType(childID, Gedcom.PedegreeLinkageType.Birth, linkTo);
									break;
								case "Adopted":
									familyRecord.SetLinkageType(childID, Gedcom.PedegreeLinkageType.Adopted, linkTo);
									break;
								default:
									System.Diagnostics.Debug.WriteLine("Unsupported value for " + _tag + ": " + _lineValue);
									break;
							}
							break;
						}
						
						break;
					default:
						GedcomCustomRecord custom = new GedcomCustomRecord();
						custom.Level = _level;
						custom.XRefID = _xrefID;
						custom.Tag = _tag;
						
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							custom.Classification = _lineValue;
						}
						
						// FIXME: may want to use customs at some point
						//familyRecord.Events.Add(custom);
						
						_ParseState.Records.Push(custom);
						break;
				}
			}
			else if (_level == familyRecord.ParsingLevel + 1)
			{
				switch (_tag)
				{
					case "RESN":
						
						// restriction notice
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							try
							{
								familyRecord.RestrictionNotice = EnumHelper.Parse<GedcomRestrictionNotice>(_lineValue,true);
							}
							catch
							{
								Debug.WriteLine("Invalid restriction type: " + _lineValue);
								
								// default to confidential to protect privacy
								familyRecord.RestrictionNotice = GedcomRestrictionNotice.Confidential;
							}
						}
						break;
					case "ANUL":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.ANUL);
						_ParseState.Records.Push(familyEvent);
					
						break;
					case "CENS":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.CENS_FAM);				
						_ParseState.Records.Push(familyEvent);
					
						break;
					case "DIV":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.DIV);				
						_ParseState.Records.Push(familyEvent);
					
						break;
					case "DIVF":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.DIVF);
						_ParseState.Records.Push(familyEvent);
					
						break;
					case "ENGA":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.ENGA);				
						_ParseState.Records.Push(familyEvent);
					
						break;
					case "MARB":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.MARB);
						_ParseState.Records.Push(familyEvent);
					
						break;
					case "MARC":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.MARC);
						_ParseState.Records.Push(familyEvent);
					
						break;
					case "MARR":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.MARR);
						_ParseState.Records.Push(familyEvent);
					
						break;
					case "MARL":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.MARL);
						_ParseState.Records.Push(familyEvent);
					
						break;
					case "MARS":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.MARS);
						_ParseState.Records.Push(familyEvent);
					
						break;	
					case "RESI":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.RESI);
						_ParseState.Records.Push(familyEvent);
					
						break;
					case "EVEN":
						
						// event
						familyEvent = familyRecord.AddNewEvent(GedcomEvent.GedcomEventType.GenericEvent);
					
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							familyEvent.EventName = _lineValue;
						}
										
						_ParseState.Records.Push(familyEvent);
					
						break;
					
					case "HUSB":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							familyRecord.Husband = _lineValue;
							_missingReferences.Add(_lineValue);
						}
						break;
					case "WIFE":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							familyRecord.Wife = _lineValue;
							_missingReferences.Add(_lineValue);
						}
						break;
					case "CHIL":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							familyRecord.Children.Add(_lineValue);
							_missingReferences.Add(_lineValue);
						}
						break;
					case "NCHI":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							try
							{
								familyRecord.NumberOfChildren = Convert.ToInt32(_lineValue);
							}
							catch
							{
								Debug.WriteLine("Invalid number for Number of children tag");
							}
						}
						break;
					case "SUBM":
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							familyRecord.SubmitterRecords.Add(_lineValue);
							_missingReferences.Add(_lineValue);
						}
						else
						{
							GedcomSubmitterRecord submitter = new GedcomSubmitterRecord();
							submitter.Level = 0; // new top level submitter, always 0;
							submitter.ParsingLevel = _level;
							submitter.XRefID = Database.GenerateXref("SUBM");
							
							_ParseState.Records.Push(submitter);
							
							familyRecord.SubmitterRecords.Add(submitter.XRefID);
						}
						
						break;
					case "FIXME?????":
						// lds spouse sealing
						break;
					case "REFN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							familyRecord.UserReferenceNumber = _lineValue;
						}
						break;
					case "RIN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							familyRecord.AutomatedRecordID = _lineValue;	
						}
						break;
					case "CHAN":
						GedcomChangeDate date = new GedcomChangeDate(Database);
						date.Level = _level;
						_ParseState.Records.Push(date);
						break;
					case "NOTE":
					    AddNoteRecord(familyRecord);
						break;
					case "SOUR":
					    AddSourceCitation(familyRecord);				
						break;
					case "OBJE":
						AddMultimediaRecord(familyRecord);
						break;
				}
			}
			else if ( (!string.IsNullOrEmpty(_ParseState.PreviousTag)) &&
			            _ParseState.PreviousTag == "REFN" &&
			            _level == _ParseState.PreviousLevel + 1)
			{
				if (_tag == "TYPE")
				{
					if (_lineValueType == GedcomLineValueType.DataType)
					{
						familyRecord.UserReferenceType = _lineValue;
					}
				}
			}
			// not valid GEDCOM, but Family Tree Maker adds ADOP/FOST tags
			// to CHIL in a FAM, this is apparently valid in GEDCOM < 5.5
			else if ( (!string.IsNullOrEmpty(_ParseState.PreviousTag)) &&
			         _ParseState.PreviousTag == "CHIL" &&
			         _level == _ParseState.PreviousLevel + 1)
			{
				string childID = familyRecord.Children[familyRecord.Children.Count - 1];
				switch (_tag)
				{
					case "ADOP":
						switch (_lineValue)
						{
							case "HUSB":
								familyRecord.SetLinkageType(childID, Gedcom.PedegreeLinkageType.Adopted, Gedcom.GedcomAdoptionType.Husband);
								break;
							case "WIFE":
								familyRecord.SetLinkageType(childID, Gedcom.PedegreeLinkageType.Adopted, Gedcom.GedcomAdoptionType.Wife);
								break;
							case "BOTH":
							default:
								familyRecord.SetLinkageType(childID, Gedcom.PedegreeLinkageType.Adopted);
								break;
						}
						break;
					case "FOST":
						switch (_lineValue)
						{
							case "HUSB":
								familyRecord.SetLinkageType(childID, Gedcom.PedegreeLinkageType.Foster, Gedcom.GedcomAdoptionType.Husband);
								break;
							case "WIFE":
								familyRecord.SetLinkageType(childID, Gedcom.PedegreeLinkageType.Foster, Gedcom.GedcomAdoptionType.Wife);
								break;
							case "BOTH":
							default:
								familyRecord.SetLinkageType(childID, Gedcom.PedegreeLinkageType.Foster);
								break;
						}
						break;
				}
			}
			else
			{
				// shouldn't be here
				Debug.WriteLine("Unknown state / tag parsing family node: " + _tag + "\t at level: " + _level);
			}
		}