public static ITextPersistent ObjectRead(TextReader rea, char separator, ref string firstLine) { if (firstLine == null) { firstLine = rea.ReadLine(); } int version, type; if (firstLine.Length < 6) { return(null); } string[] tokens = firstLine.Split(separator); if (tokens.Length < 4) { return(null); } ITextPersistent mother = GetMother(tokens[1]); if (mother == null || !int.TryParse(tokens[2], out version) || !int.TryParse(tokens[3], out type)) { return(null); } firstLine = null; return(mother.TextRead(rea, separator, ref firstLine, version, type)); }
/// <summary> /// |class|version|type|[size] /// </summary> public static List <ITextPersistent> ArrayRead(TextReader rea, char separator, ref string firstLine, HashSet <string> banned = null) { if (firstLine == null) { firstLine = rea.ReadLine(); } int version, type; if (firstLine.Length < 3) { return(null); } string[] tokens = firstLine.Split(separator); if (tokens.Length < 5) { return(null); } if (banned != null && banned.Contains(tokens[1])) { return(null); } ITextPersistent mother = GetMother(tokens[1]); if (mother == null || !int.TryParse(tokens[2], out version) || !int.TryParse(tokens[3], out type)) { return(null); } List <ITextPersistent> l = new List <ITextPersistent>(); do { firstLine = rea.ReadLine(); if (firstLine == null) { break; } if (firstLine.Length == 2 && firstLine[0] == separator && firstLine[1] == separator) { firstLine = null; break; } ITextPersistent elem = mother.TextRead(rea, separator, ref firstLine, version, type); if (elem == null) { break; } l.Add(elem); } while (true); return(l); }