public override bool Read() { bool success = _reader.Read(); switch (_reader.TokenType) { case BionToken.EndArray: SetToken(JsonToken.EndArray); break; case BionToken.EndObject: SetToken(JsonToken.EndObject); break; case BionToken.False: SetToken(JsonToken.Boolean, false); break; case BionToken.Float: SetToken(JsonToken.Float, _reader.CurrentFloat()); break; case BionToken.Integer: SetToken(JsonToken.Integer, (int)_reader.CurrentInteger()); break; case BionToken.None: SetToken(JsonToken.None); break; case BionToken.Null: SetToken(JsonToken.Null, null); break; case BionToken.PropertyName: SetToken(JsonToken.PropertyName, _reader.CurrentString()); break; case BionToken.StartArray: SetToken(JsonToken.StartArray); break; case BionToken.StartObject: SetToken(JsonToken.StartObject); break; case BionToken.String: SetToken(JsonToken.String, _reader.CurrentString()); break; case BionToken.True: SetToken(JsonToken.Boolean, true); break; default: throw new NotImplementedException($"BionDataReader.Convert not implemented for '{_reader.TokenType}'."); } return(success); }
public static void WriteToken(BionReader reader, JsonTextWriter writer) { switch (reader.TokenType) { case BionToken.StartObject: writer.WriteStartObject(); break; case BionToken.StartArray: writer.WriteStartArray(); break; case BionToken.EndObject: writer.WriteEndObject(); break; case BionToken.EndArray: writer.WriteEndArray(); break; case BionToken.PropertyName: writer.WritePropertyName(reader.CurrentString()); break; case BionToken.String: writer.WriteValue(reader.CurrentString()); break; case BionToken.Integer: writer.WriteValue(reader.CurrentInteger()); break; case BionToken.Float: writer.WriteValue(reader.CurrentFloat()); break; case BionToken.True: case BionToken.False: writer.WriteValue(reader.CurrentBool()); break; case BionToken.Null: writer.WriteNull(); break; default: throw new NotImplementedException($"BionToJson not implemented for {reader.TokenType} @{reader.BytesRead}."); } }