using System.IO; namespace Com.Xagasoft.Gats { public abstract class GatsObject { public abstract void Read( Stream s, char type ); public abstract void Write( Stream s ); public static GatsObject Read( Stream s ) { int b = s.ReadByte(); if( b == -1 ) throw new GatsException( GatsException.Type.PrematureEnd ); char type = (char)b; GatsObject goRet = null; switch( type ) { case 'i': goRet = new GatsInteger(); break; case 's': goRet = new GatsString(); break; case '0': case '1': goRet = new GatsBoolean(); break; case 'l': // goRet = new GatsList(); break; case 'd': // goRet = new GatsDictionary(); break; case 'f': case 'F': goRet = new GatsFloat(); break; case 'n': goRet = new GatsNull(); break; case 'e': return null; default: throw new GatsException( GatsException.Type.InvalidType ); } goRet.Read( s, type ); return goRet; } } }