public bool MoveNext() { ThrowIfDisposed(); if (state == TableEntityReaderState.Done) { return(false); } JsonToken jsonToken = PopToken(); if (jsonToken.Type == JsonTokenType.EndObject) { state = TableEntityReaderState.Done; return(false); } if (jsonToken.Type == JsonTokenType.String) { currentName = jsonToken.GetStringValue(); } else { ThrowFormatException("Expecting a name but found '{0}'", jsonToken.Lexeme); } Expect(JsonTokenType.Colon); JsonToken jsonToken2 = PopToken(); if (EdmSchemaMapping.IsDocumentDBProperty(currentName) || currentName == "$pk" || currentName == "$id") { switch (jsonToken2.Type) { case JsonTokenType.String: currentEdmType = DataType.String; currentValue = jsonToken2; break; case JsonTokenType.Number: currentEdmType = DataType.Double; currentValue = jsonToken2; break; default: ThrowFormatException("Unexpected value type '{0}' for DocumentDB property.", jsonToken2.Type); break; } } else { if (jsonToken2.Type != JsonTokenType.BeginObject) { ThrowFormatException("Value is expected to be an object instead it was '{0}'.", jsonToken2.Type); } currentEdmType = ParseEdmType(); } TryReadComma(); state = TableEntityReaderState.HasValue; return(true); }
public void WriteName(string name) { if (name == null) { throw new ArgumentException("name"); } if (name.StartsWith(EdmSchemaMapping.SystemPropertiesPrefix, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException("name"); } ThrowIfDisposed(); ThrowIfInvalidState("WriteName", TableEntityWriterState.Name); if (EdmSchemaMapping.IsDocumentDBProperty(name)) { elemantName = EdmSchemaMapping.SystemPropertiesPrefix + name; } else { elemantName = name; } state = TableEntityWriterState.Value; }