/// <summary> /// Parses the Gedcom file that is read from the stream /// </summary> /// <param name="stream">stream that the Gedcom is read from</param> /// <returns>a LineageLinkedGedcom object, that contains the read information</returns> public LineageLinkedGedcom Parse(Stream stream) { var lineNumber = 0; objects = new Stack <object>(); tags = new Stack <string>(); var gedcom = new LineageLinkedGedcom(reporting); objects.Push(gedcom); lastLevel = -1; using (var streamReader = new StreamReader(stream)) { string str; while ((str = streamReader.ReadLine()) != null) { try { ProcessLine(str, ++lineNumber); } catch (NullReferenceException) { throw; } }
/// <summary> /// write the gedcom object to the stream /// </summary> /// <param name="gedcom">the lineage linked gedcom object that shoulde be written</param> /// <param name="stream">the stream that the gedcom object should be written to</param> public void Write(LineageLinkedGedcom gedcom, Stream stream) { var streamWriter = new StreamWriter(stream) { AutoFlush = true }; WriteObject(gedcom, "", streamWriter, -1, ""); }