diff options
Diffstat (limited to '')
-rw-r--r-- | cs-dotnet/src/gatsobject.cs | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/cs-dotnet/src/gatsobject.cs b/cs-dotnet/src/gatsobject.cs index f782f95..a0b9276 100644 --- a/cs-dotnet/src/gatsobject.cs +++ b/cs-dotnet/src/gatsobject.cs | |||
@@ -4,7 +4,58 @@ namespace Com.Xagasoft.Gats | |||
4 | { | 4 | { |
5 | public abstract class GatsObject | 5 | public abstract class GatsObject |
6 | { | 6 | { |
7 | public abstract void Read( Stream s, byte cType ); | 7 | public abstract void Read( Stream s, char cType ); |
8 | public abstract void Write( Stream s ); | 8 | public abstract void Write( Stream s ); |
9 | |||
10 | public static GatsObject Read( Stream s ) | ||
11 | { | ||
12 | int b = s.ReadByte(); | ||
13 | if( b == -1 ) | ||
14 | throw new GatsException( GatsException.Type.PrematureEnd ); | ||
15 | char type = (char)b; | ||
16 | GatsObject goRet = null; | ||
17 | switch( type ) | ||
18 | { | ||
19 | case 'i': | ||
20 | goRet = new GatsInteger(); | ||
21 | break; | ||
22 | |||
23 | case 's': | ||
24 | goRet = new GatsString(); | ||
25 | break; | ||
26 | |||
27 | case '0': | ||
28 | case '1': | ||
29 | goRet = new GatsBoolean(); | ||
30 | break; | ||
31 | |||
32 | case 'l': | ||
33 | // goRet = new GatsList(); | ||
34 | break; | ||
35 | |||
36 | case 'd': | ||
37 | // goRet = new GatsDictionary(); | ||
38 | break; | ||
39 | |||
40 | case 'f': | ||
41 | case 'F': | ||
42 | // goRet = new GatsFloat(); | ||
43 | break; | ||
44 | |||
45 | case 'n': | ||
46 | // goRet = new GatsNull(); | ||
47 | break; | ||
48 | |||
49 | case 'e': | ||
50 | return null; | ||
51 | |||
52 | default: | ||
53 | throw new GatsException( GatsException.Type.InvalidType ); | ||
54 | } | ||
55 | |||
56 | goRet.Read( s, type ); | ||
57 | |||
58 | return goRet; | ||
59 | } | ||
9 | } | 60 | } |
10 | } | 61 | } |