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);
        }
 public static void Register(ITextPersistent mother, int version)
 {
     Registry.Add(mother.PersName, mother); // version is ignored so far
 }
 public static void ArrayWriteProlog(TextWriter wri, char separator, ITextPersistent classInstance, int version, int type)
 {
     wri.WriteLine("{0}{1}{0}{2}{0}{3}{0}", separator, classInstance.PersName, version, type);
 }