static void DeserializeObject(TextReader reader, ObjectBuilder builder) { int c; builder.StartObject(); while (true) { Methods.ConsumeWhiteSpace(reader); c = reader.Peek(); if (c == -1) { throw new DeserializationException("Unexpected end of stream", reader, true); } if (c == '}') { reader.Read(); // skip } break; } c = reader.Read(); if (c == -1) { throw new DeserializationException("Unexpected end of stream", reader, true); } if (c != '"') { throw new DeserializationException("Expected \", found " + (char)c, reader, false); } builder.StartObjectMember(); DeserializeString(reader, builder); Methods.ConsumeWhiteSpace(reader); c = reader.Read(); if (c == -1) { throw new DeserializationException("Unexpected end of stream", reader, true); } if (c != ':') { throw new DeserializationException("Expected :, found " + (char)c, reader, false); } _DeserializeMember(reader, builder); builder.EndObjectMember(); Methods.ConsumeWhiteSpace(reader); c = reader.Read(); if (c == ',') { continue; } if (c == '}') { break; } if (c == -1) { throw new DeserializationException("Unexpected end of stream", reader, true); } throw new DeserializationException("Expected , or }, found " + (char)c, reader, false); } builder.EndObject(); }
static void DeserializeObjectThunkReader(ref ThunkReader reader, ObjectBuilder builder) { int c; builder.StartObject(); while (true) { Methods.ConsumeWhiteSpaceThunkReader(ref reader); c = reader.Peek(); if (c == -1) throw new DeserializationException("Unexpected end of stream", ref reader, true); if (c == '}') { reader.Read(); // skip } break; } c = reader.Read(); if (c == -1) throw new DeserializationException("Unexpected end of stream", ref reader, true); if (c != '"') throw new DeserializationException("Expected \", found " + (char)c, ref reader, false); builder.StartObjectMember(); DeserializeStringThunkReader(ref reader, builder); Methods.ConsumeWhiteSpaceThunkReader(ref reader); c = reader.Read(); if (c == -1) throw new DeserializationException("Unexpected end of stream", ref reader, true); if (c != ':') throw new DeserializationException("Expected :, found " + (char)c, ref reader, false); _DeserializeMemberThunkReader(ref reader, builder); builder.EndObjectMember(); Methods.ConsumeWhiteSpaceThunkReader(ref reader); c = reader.Read(); if (c == ',') continue; if (c == '}') break; if (c == -1) throw new DeserializationException("Unexpected end of stream", ref reader, true); throw new DeserializationException("Expected , or }, found " + (char)c, ref reader, false); } builder.EndObject(); }