Exemplo n.º 1
0
		/// <summary>
		/// Create a GedcomRecordReader for reading a GEDCOM file into a GedcomDatabase
		/// </summary>
		public GedcomRecordReader()
		{
			_Parser = new GedcomParser();

			// we don't care if delims are multiple spaces
			_Parser.IgnoreInvalidDelim = true;

			// we don't care if lines are missing delimeters
			_Parser.IgnoreMissingTerms = true;
			
			// apply hack for lines that are just part of the line value
			// for the previous CONC/CONT in invalid GEDCOM files
			_Parser.ApplyConcContOnNewLineHack = true;

			// allow tabs in line values, seen from RootsMagic and GenealogyJ
			_Parser.AllowTabs = true;

			// allow line tabs in line values, seen from Legacy
			_Parser.AllowLineTabs = true;
			
			// allow information separator one chars, seen from that bastion
			// of spec compliance RootsMagic
			_Parser.AllowInformationSeparatorOne = true;

			// allow - or _ in tag names (GenealogyJ?)
			_Parser.AllowHyphenOrUnderscoreInTag = true;
			
			_Parser.ParserError += Parser_ParseError;
			_Parser.TagFound += Parser_TagFound;
		}
Exemplo n.º 2
0
		private void Parse(string file, Encoding encoder, bool allowTabs, bool allowHyphenOrUnderscoreInTag)
		{
			string dir = "/home/david/Projects/Gedcom.NET/Data/tests";
			
			GedcomParser parser = new GedcomParser();
			
			parser.AllowTabs = allowTabs;
			parser.AllowHyphenOrUnderscoreInTag = allowHyphenOrUnderscoreInTag;
			
			parser.ParserError += GedcomParser_ParseError;
			parser.TagFound += GedcomParser_TagFound;
			
			
			string gedcomFile = Path.Combine(dir,file);
			
			FileStream stream = null;
			try
			{
				FileInfo fi = new FileInfo(gedcomFile);
				stream = fi.OpenRead();
								
				int bufferSize = (int)fi.Length;
				byte[] buffer = new byte[bufferSize];
				int read = 0;								
				while( (read = stream.Read(buffer,0,bufferSize)) != 0)
				{
					System.Console.WriteLine("Read into buffer");
					string input = encoder.GetString(buffer,0,read).Trim();
					System.Console.WriteLine("Got string");
					System.Console.WriteLine("Begin Parse: " + gedcomFile);
					parser.GedcomParse(input);					
				}
			}
			finally
			{
				if (stream != null)
				{
					stream.Close();
				}
			}
		}