public void Write(TBufferBase ab) { if (ab != null) { ab.Encode(this); } }
public TBufferBase Read(ref TBufferBase ab) { if (ab != null) { ab.Decode(this); } return(ab); }
public object Read <T>(ref T o) { if (o == null) { o = (T)BasicClassTypeUtil.CreateObject <T>(); } if (o is Byte || o is Char) { byte b = 0; o = (T)(object)(Read(ref b)); } else if (o is char) { byte c = 0; o = (T)(object)(Read(ref c)); } else if (o is Boolean) { bool b = false; o = (T)(object)(Read(ref b)); } else if (o is short) { short s = 0; o = (T)(object)(Read(ref s)); } else if (o is ushort) { ushort us = 0; o = (T)(object)(Read(ref us)); } else if (o is int) { int i = 0; o = (T)(object)Read(ref i); } else if (o is uint) { uint ui = 0; o = (T)(object)Read(ref ui); return(o); } else if (o is long) { long l = 0; o = (T)(object)Read(ref l); return(o); } else if (o is Enum) { int remp = 0; o = (T)(object)Read(ref remp); return(o); } else if (o is ulong) { ulong ul = 0; object oo = (Read(ref ul)); o = (T)oo; return(oo); } /* * else if (o is float) * { * return (Read()); * } * else if (o is Double) * { * return (Read()); * }*/ else if (o is string) { string s = ""; o = (T)(object)Read(ref s); } else if (o is TBufferBase) { TBufferBase oo = o as TBufferBase; o = (T)(object)Read(ref oo); } else if (o != null && o.GetType().IsArray) { /* * if (o is byte[] || o is Byte[]) * { * return Read((byte[])null); * } * else if (o is bool[]) * { * return Read((bool[])null); * } * else if (o is short[]) * { * return Read((short[])null); * } * else if (o is int[]) * { * return Read((int[])null); * } * else if (o is long[]) * { * return Read((long[])null); * } * else if (o is float[]) * { * return Read((float[])null); * } * else if (o is double[]) * { * return Read((double[])null); * } * else * { * object oo = o; * return readArray((Object[])oo); * } */ } else if (o is IList) { return(ReadList <T>(ref o)); } else if (o is IDictionary) { return(ReadMap <T>(ref o)); } else { throw new Exception("read object error: unsupport type:" + o.GetType() + " value:" + o.ToString()); } return(o); }