public override byte[] Read(Reader reader, int tag) { var stream = reader.Stream; switch (tag) { case TagBytes: return(ReferenceReader.ReadBytes(reader)); case TagEmpty: return(empty); case TagList: return(ReferenceReader.ReadArray <byte>(reader)); case TagUTF8Char: return(Converter <byte[]> .Convert(ValueReader.ReadUTF8Char(stream))); case TagString: return(Converter <byte[]> .Convert(ReferenceReader.ReadChars(reader))); case TagGuid: return(Converter <byte[]> .Convert(ReferenceReader.ReadGuid(reader))); default: return(base.Read(reader, tag)); } }
public override StringBuilder Read(Reader reader, int tag) { var stream = reader.Stream; switch (tag) { case TagString: return(Converter <StringBuilder> .Convert(ReferenceReader.ReadString(reader))); case TagUTF8Char: return(new StringBuilder(1).Append(ValueReader.ReadChar(stream))); case TagList: return(Converter <StringBuilder> .Convert(ReferenceReader.ReadArray <char>(reader))); case TagInteger: case TagLong: case TagDouble: return(ValueReader.ReadUntil(stream, TagSemicolon)); case TagEmpty: return(new StringBuilder()); case TagTrue: return(new StringBuilder(bool.TrueString)); case TagFalse: return(new StringBuilder(bool.FalseString)); case TagNaN: return(new StringBuilder(double.NaN.ToString())); case TagInfinity: return(new StringBuilder(ValueReader.ReadInfinity(stream).ToString())); case TagDate: return(Converter <StringBuilder> .Convert(ReferenceReader.ReadDateTime(reader))); case TagTime: return(Converter <StringBuilder> .Convert(ReferenceReader.ReadTime(reader))); case TagGuid: return(Converter <StringBuilder> .Convert(ReferenceReader.ReadGuid(reader))); case TagBytes: return(Converter <StringBuilder> .Convert(ReferenceReader.ReadBytes(reader))); default: if (tag >= '0' && tag <= '9') { return(new StringBuilder(1).Append((char)tag)); } return(base.Read(reader, tag)); } }
public override Guid Read(Reader reader, int tag) { switch (tag) { case TagGuid: return(ReferenceReader.ReadGuid(reader)); case TagBytes: return(Converter <Guid> .Convert(ReferenceReader.ReadBytes(reader))); case TagString: return(Converter <Guid> .Convert(ReferenceReader.ReadString(reader))); default: return(base.Read(reader, tag)); } }
public override string Read(Reader reader, int tag) { var stream = reader.Stream; switch (tag) { case TagString: return(ReferenceReader.ReadString(reader)); case TagUTF8Char: return(ValueReader.ReadUTF8Char(stream)); case '0': return("0"); case '1': return("1"); case '2': return("2"); case '3': return("3"); case '4': return("4"); case '5': return("5"); case '6': return("6"); case '7': return("7"); case '8': return("8"); case '9': return("9"); case TagInteger: case TagLong: case TagDouble: return(ValueReader.ReadUntil(stream, TagSemicolon).ToString()); case TagEmpty: return(""); case TagTrue: return(bool.TrueString); case TagFalse: return(bool.FalseString); case TagNaN: return(double.NaN.ToString()); case TagInfinity: return(ValueReader.ReadInfinity(stream).ToString()); case TagDate: return(ReferenceReader.ReadDateTime(reader).ToString()); case TagTime: return(ReferenceReader.ReadTime(reader).ToString()); case TagGuid: return(ReferenceReader.ReadGuid(reader).ToString()); case TagBytes: return(Converter <string> .Convert(ReferenceReader.ReadBytes(reader))); case TagList: return(Converter <string> .Convert(ReferenceReader.ReadArray <char>(reader))); default: return(base.Read(reader, tag)); } }
public override object Read(Reader reader, int tag) { if (tag >= '0' && tag <= '9') { return(digitObject[tag - '0']); } var stream = reader.Stream; switch (tag) { case TagInteger: return(ValueReader.ReadInt(stream)); case TagString: return(ReferenceReader.ReadString(reader)); case TagBytes: return(ReferenceReader.ReadBytes(reader)); case TagTrue: return(trueObject); case TagFalse: return(falseObject); case TagEmpty: return(""); case TagObject: return(Read(reader)); case TagRef: return(reader.ReadReference()); case TagDate: return(ReferenceReader.ReadDateTime(reader)); case TagTime: return(ReferenceReader.ReadTime(reader)); case TagGuid: return(ReferenceReader.ReadGuid(reader)); case TagLong: switch (reader.LongType) { case LongType.Int64: return(ValueReader.ReadLong(stream)); case LongType.UInt64: return((ulong)ValueReader.ReadLong(stream)); default: return(ValueReader.ReadBigInteger(stream)); } case TagDouble: switch (reader.RealType) { case RealType.Single: return(ValueReader.ReadSingle(stream)); case RealType.Decimal: return(ValueReader.ReadDecimal(stream)); default: return(ValueReader.ReadDouble(stream)); } case TagNaN: switch (reader.RealType) { case RealType.Single: return(float.NaN); default: return(double.NaN); } case TagInfinity: switch (reader.RealType) { case RealType.Single: return(ValueReader.ReadSingleInfinity(stream)); default: return(ValueReader.ReadInfinity(stream)); } case TagUTF8Char: switch (reader.CharType) { case CharType.Char: return(ValueReader.ReadChar(stream)); default: return(ValueReader.ReadUTF8Char(stream)); } case TagList: switch (reader.ListType) { case ListType.Array: return(ReferenceReader.ReadArray <object>(reader)); case ListType.ArrayList: return(ListDeserializer <ArrayList> .Read(reader)); default: return(CollectionDeserializer <List <object>, object> .Read(reader)); } case TagMap: switch (reader.DictType) { case DictType.Dictionary: return(DictionaryDeserializer <Dictionary <object, object>, object, object> .Read(reader)); case DictType.ExpandoObject: return(ExpandoObjectDeserializer.Read(reader)); case DictType.Hashtable: return(DictionaryDeserializer <Hashtable> .Read(reader)); default: return(DictionaryDeserializer <NullableKeyDictionary <object, object>, object, object> .Read(reader)); } case TagError: return(new Exception(reader.Deserialize <string>())); default: return(base.Read(reader, tag)); } }