internal void ReadContentFrom(JsonReader r) { ValidationUtils.ArgumentNotNull(r, "r"); IJsonLineInfo lineInfo = r as IJsonLineInfo; JContainer jContainer = this; do { if (jContainer is JProperty && ((JProperty)jContainer).Value != null) { if (jContainer == this) { break; } jContainer = jContainer.Parent; } switch (r.TokenType) { case JsonToken.StartArray: { JArray jArray = new JArray(); jArray.SetLineInfo(lineInfo); jContainer.Add(jArray); jContainer = jArray; break; } case JsonToken.EndArray: if (jContainer == this) { return; } jContainer = jContainer.Parent; break; case JsonToken.StartObject: { JObject jObject2 = new JObject(); jObject2.SetLineInfo(lineInfo); jContainer.Add(jObject2); jContainer = jObject2; break; } case JsonToken.EndObject: if (jContainer == this) { return; } jContainer = jContainer.Parent; break; case JsonToken.StartConstructor: { JConstructor jConstructor = new JConstructor(r.Value.ToString()); jConstructor.SetLineInfo(jConstructor); jContainer.Add(jConstructor); jContainer = jConstructor; break; } case JsonToken.EndConstructor: if (jContainer == this) { return; } jContainer = jContainer.Parent; break; case JsonToken.Integer: case JsonToken.Float: case JsonToken.String: case JsonToken.Boolean: case JsonToken.Date: case JsonToken.Bytes: { JValue jValue = new JValue(r.Value); jValue.SetLineInfo(lineInfo); jContainer.Add(jValue); break; } case JsonToken.Comment: { JValue jValue = JValue.CreateComment(r.Value.ToString()); jValue.SetLineInfo(lineInfo); jContainer.Add(jValue); break; } case JsonToken.Null: { JValue jValue = new JValue(null, JTokenType.Null); jValue.SetLineInfo(lineInfo); jContainer.Add(jValue); break; } case JsonToken.Undefined: { JValue jValue = new JValue(null, JTokenType.Undefined); jValue.SetLineInfo(lineInfo); jContainer.Add(jValue); break; } case JsonToken.PropertyName: { string name = r.Value.ToString(); JProperty jProperty = new JProperty(name); jProperty.SetLineInfo(lineInfo); JObject jObject = (JObject)jContainer; JProperty jProperty2 = jObject.Property(name); if (jProperty2 == null) { jContainer.Add(jProperty); } else { jProperty2.Replace(jProperty); } jContainer = jProperty; break; } default: throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType)); case JsonToken.None: break; } }while (r.Read()); }
private async Task ReadContentFromAsync(JsonReader reader, JsonLoadSettings?settings, CancellationToken cancellationToken = default) { IJsonLineInfo?lineInfo = reader as IJsonLineInfo; JContainer?parent = this; do { if (parent is JProperty p && p.Value != null) { if (parent == this) { return; } parent = parent.Parent; } MiscellaneousUtils.Assert(parent != null); switch (reader.TokenType) { case JsonToken.None: // new reader. move to actual content break; case JsonToken.StartArray: JArray a = new JArray(); a.SetLineInfo(lineInfo, settings); parent.Add(a); parent = a; break; case JsonToken.EndArray: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.StartObject: JObject o = new JObject(); o.SetLineInfo(lineInfo, settings); parent.Add(o); parent = o; break; case JsonToken.EndObject: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.StartConstructor: JConstructor constructor = new JConstructor(reader.Value !.ToString()); constructor.SetLineInfo(lineInfo, settings); parent.Add(constructor); parent = constructor; break; case JsonToken.EndConstructor: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.String: case JsonToken.Integer: case JsonToken.Float: case JsonToken.Date: case JsonToken.Boolean: case JsonToken.Bytes: JValue v = new JValue(reader.Value); v.SetLineInfo(lineInfo, settings); parent.Add(v); break; case JsonToken.Comment: if (settings != null && settings.CommentHandling == CommentHandling.Load) { v = JValue.CreateComment(reader.Value !.ToString()); v.SetLineInfo(lineInfo, settings); parent.Add(v); } break; case JsonToken.Null: v = JValue.CreateNull(); v.SetLineInfo(lineInfo, settings); parent.Add(v); break; case JsonToken.Undefined: v = JValue.CreateUndefined(); v.SetLineInfo(lineInfo, settings); parent.Add(v); break; case JsonToken.PropertyName: JProperty?property = ReadProperty(reader, settings, lineInfo, parent); if (property != null) { parent = property; } else { await reader.SkipAsync().ConfigureAwait(false); } break; default: throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, reader.TokenType)); } } while (await reader.ReadAsync(cancellationToken).ConfigureAwait(false)); }
internal void ReadContentFrom(JsonReader r, JsonLoadSettings settings) { ValidationUtils.ArgumentNotNull(r, nameof(r)); IJsonLineInfo lineInfo = r as IJsonLineInfo; JContainer parent = this; do { if ((parent as JProperty)?.Value != null) { if (parent == this) { return; } parent = parent.Parent; } switch (r.TokenType) { case JsonToken.None: // new reader. move to actual content break; case JsonToken.StartArray: JArray a = new JArray(); a.SetLineInfo(lineInfo, settings); parent.Add(a); parent = a; break; case JsonToken.EndArray: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.StartObject: JObject o = new JObject(); o.SetLineInfo(lineInfo, settings); parent.Add(o); parent = o; break; case JsonToken.EndObject: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.StartConstructor: JConstructor constructor = new JConstructor(r.Value.ToString()); constructor.SetLineInfo(lineInfo, settings); parent.Add(constructor); parent = constructor; break; case JsonToken.EndConstructor: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.String: case JsonToken.Integer: case JsonToken.Float: case JsonToken.Date: case JsonToken.Boolean: case JsonToken.Bytes: JValue v = new JValue(r.Value); v.SetLineInfo(lineInfo, settings); parent.Add(v); break; case JsonToken.Comment: if (settings != null && settings.CommentHandling == CommentHandling.Load) { v = JValue.CreateComment(r.Value.ToString()); v.SetLineInfo(lineInfo, settings); parent.Add(v); } break; case JsonToken.Null: v = JValue.CreateNull(); v.SetLineInfo(lineInfo, settings); parent.Add(v); break; case JsonToken.Undefined: v = JValue.CreateUndefined(); v.SetLineInfo(lineInfo, settings); parent.Add(v); break; case JsonToken.PropertyName: string propertyName = r.Value.ToString(); JProperty property = new JProperty(propertyName); property.SetLineInfo(lineInfo, settings); JObject parentObject = (JObject)parent; // handle multiple properties with the same name in JSON JProperty existingPropertyWithName = parentObject.Property(propertyName); if (existingPropertyWithName == null) { parent.Add(property); } else { existingPropertyWithName.Replace(property); } parent = property; break; default: throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType)); } } while (r.Read()); }
internal void ReadContentFrom(JsonReader r) { ValidationUtils.ArgumentNotNull(r, "r"); IJsonLineInfo lineInfo = r as IJsonLineInfo; JContainer parent = this; do { if (parent is JProperty && ((JProperty)parent).Value != null) { if (parent == this) { return; } parent = parent.Parent; } switch (r.TokenType) { case JsonToken.None: // new reader. move to actual content break; case JsonToken.StartArray: JArray a = new JArray(); a.SetLineInfo(lineInfo); parent.AddObjectSkipNotify(a); parent = a; break; case JsonToken.EndArray: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.StartObject: JObject o = new JObject(); o.SetLineInfo(lineInfo); parent.AddObjectSkipNotify(o); parent = o; break; case JsonToken.EndObject: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.StartConstructor: JConstructor constructor = new JConstructor(r.Value.ToString()); constructor.SetLineInfo(constructor); parent.AddObjectSkipNotify(constructor); parent = constructor; break; case JsonToken.EndConstructor: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.String: case JsonToken.Integer: case JsonToken.Float: case JsonToken.Date: case JsonToken.Boolean: JValue v = new JValue(r.Value); v.SetLineInfo(lineInfo); parent.AddObjectSkipNotify(v); break; case JsonToken.Comment: v = JValue.CreateComment(r.Value.ToString()); v.SetLineInfo(lineInfo); parent.AddObjectSkipNotify(v); break; case JsonToken.Null: v = new JValue(null, JTokenType.Null); v.SetLineInfo(lineInfo); parent.AddObjectSkipNotify(v); break; case JsonToken.Undefined: v = new JValue(null, JTokenType.Undefined); v.SetLineInfo(lineInfo); parent.AddObjectSkipNotify(v); break; case JsonToken.PropertyName: JProperty property = new JProperty(r.Value.ToString()); property.SetLineInfo(lineInfo); parent.AddObjectSkipNotify(property); parent = property; break; default: throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType)); } }while (r.Read()); }
internal void ReadContentFrom(JsonReader r) { ValidationUtils.ArgumentNotNull(r, "r"); IJsonLineInfo lineInfo = r as IJsonLineInfo; JContainer jcontainer = this; for (;;) { if (jcontainer is JProperty && ((JProperty)jcontainer).Value != null) { if (jcontainer == this) { break; } jcontainer = jcontainer.Parent; } switch (r.TokenType) { case JsonToken.None: goto IL_244; case JsonToken.StartObject: { JObject jobject = new JObject(); jobject.SetLineInfo(lineInfo); jcontainer.Add(jobject); jcontainer = jobject; goto IL_244; } case JsonToken.StartArray: { JArray jarray = new JArray(); jarray.SetLineInfo(lineInfo); jcontainer.Add(jarray); jcontainer = jarray; goto IL_244; } case JsonToken.StartConstructor: { JConstructor jconstructor = new JConstructor(r.Value.ToString()); jconstructor.SetLineInfo(jconstructor); jcontainer.Add(jconstructor); jcontainer = jconstructor; goto IL_244; } case JsonToken.PropertyName: { string name = r.Value.ToString(); JProperty jproperty = new JProperty(name); jproperty.SetLineInfo(lineInfo); JObject jobject2 = (JObject)jcontainer; JProperty jproperty2 = jobject2.Property(name); if (jproperty2 == null) { jcontainer.Add(jproperty); } else { jproperty2.Replace(jproperty); } jcontainer = jproperty; goto IL_244; } case JsonToken.Comment: { JValue jvalue = JValue.CreateComment(r.Value.ToString()); jvalue.SetLineInfo(lineInfo); jcontainer.Add(jvalue); goto IL_244; } case JsonToken.Integer: case JsonToken.Float: case JsonToken.String: case JsonToken.Boolean: case JsonToken.Date: case JsonToken.Bytes: { JValue jvalue = new JValue(r.Value); jvalue.SetLineInfo(lineInfo); jcontainer.Add(jvalue); goto IL_244; } case JsonToken.Null: { JValue jvalue = new JValue(null, JTokenType.Null); jvalue.SetLineInfo(lineInfo); jcontainer.Add(jvalue); goto IL_244; } case JsonToken.Undefined: { JValue jvalue = new JValue(null, JTokenType.Undefined); jvalue.SetLineInfo(lineInfo); jcontainer.Add(jvalue); goto IL_244; } case JsonToken.EndObject: if (jcontainer == this) { return; } jcontainer = jcontainer.Parent; goto IL_244; case JsonToken.EndArray: if (jcontainer == this) { return; } jcontainer = jcontainer.Parent; goto IL_244; case JsonToken.EndConstructor: if (jcontainer == this) { return; } jcontainer = jcontainer.Parent; goto IL_244; } goto Block_4; IL_244: if (!r.Read()) { return; } } return; Block_4: throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, new object[] { r.TokenType })); }
internal void ReadContentFrom(JsonReader r, JsonLoadSettings settings) { JValue jValue; bool value; ValidationUtils.ArgumentNotNull(r, "r"); IJsonLineInfo jsonLineInfo = r as IJsonLineInfo; JContainer parent = this; do { JProperty jProperty = parent as JProperty; if (jProperty != null) { value = jProperty.Value; } else { value = false; } if (value) { if (parent == this) { return; } parent = parent.Parent; } switch (r.TokenType) { case JsonToken.None: { continue; } case JsonToken.StartObject: { JObject jObjects = new JObject(); jObjects.SetLineInfo(jsonLineInfo, settings); parent.Add(jObjects); parent = jObjects; continue; } case JsonToken.StartArray: { JArray jArrays = new JArray(); jArrays.SetLineInfo(jsonLineInfo, settings); parent.Add(jArrays); parent = jArrays; continue; } case JsonToken.StartConstructor: { JConstructor jConstructor = new JConstructor(r.Value.ToString()); jConstructor.SetLineInfo(jsonLineInfo, settings); parent.Add(jConstructor); parent = jConstructor; continue; } case JsonToken.PropertyName: { string str = r.Value.ToString(); JProperty jProperty1 = new JProperty(str); jProperty1.SetLineInfo(jsonLineInfo, settings); JProperty jProperty2 = ((JObject)parent).Property(str); if (jProperty2 != null) { jProperty2.Replace(jProperty1); } else { parent.Add(jProperty1); } parent = jProperty1; continue; } case JsonToken.Comment: { if (settings == null || settings.CommentHandling != CommentHandling.Load) { continue; } jValue = JValue.CreateComment(r.Value.ToString()); jValue.SetLineInfo(jsonLineInfo, settings); parent.Add(jValue); continue; } case JsonToken.Raw: { throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType)); } case JsonToken.Integer: case JsonToken.Float: case JsonToken.String: case JsonToken.Boolean: case JsonToken.Date: case JsonToken.Bytes: { jValue = new JValue(r.Value); jValue.SetLineInfo(jsonLineInfo, settings); parent.Add(jValue); continue; } case JsonToken.Null: { jValue = JValue.CreateNull(); jValue.SetLineInfo(jsonLineInfo, settings); parent.Add(jValue); continue; } case JsonToken.Undefined: { jValue = JValue.CreateUndefined(); jValue.SetLineInfo(jsonLineInfo, settings); parent.Add(jValue); continue; } case JsonToken.EndObject: { if (parent == this) { return; } parent = parent.Parent; continue; } case JsonToken.EndArray: { if (parent == this) { return; } parent = parent.Parent; continue; } case JsonToken.EndConstructor: { if (parent == this) { return; } parent = parent.Parent; continue; } default: { throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType)); } } }while (r.Read()); }
internal void ReadContentFrom(JsonReader r) { ValidationUtils.ArgumentNotNull((object)r, "r"); IJsonLineInfo lineInfo = r as IJsonLineInfo; JContainer jcontainer = this; do { if (jcontainer is JProperty && ((JProperty)jcontainer).Value != null) { if (jcontainer == this) { break; } jcontainer = jcontainer.Parent; } switch (r.TokenType) { case JsonToken.None: continue; case JsonToken.StartObject: JObject jobject = new JObject(); jobject.SetLineInfo(lineInfo); jcontainer.Add((object)jobject); jcontainer = (JContainer)jobject; goto case 0; case JsonToken.StartArray: JArray jarray = new JArray(); jarray.SetLineInfo(lineInfo); jcontainer.Add((object)jarray); jcontainer = (JContainer)jarray; goto case 0; case JsonToken.StartConstructor: JConstructor jconstructor = new JConstructor(r.Value.ToString()); jconstructor.SetLineInfo((IJsonLineInfo)jconstructor); jcontainer.Add((object)jconstructor); jcontainer = (JContainer)jconstructor; goto case 0; case JsonToken.PropertyName: string name = r.Value.ToString(); JProperty jproperty1 = new JProperty(name); jproperty1.SetLineInfo(lineInfo); JProperty jproperty2 = ((JObject)jcontainer).Property(name); if (jproperty2 == null) { jcontainer.Add((object)jproperty1); } else { jproperty2.Replace((JToken)jproperty1); } jcontainer = (JContainer)jproperty1; goto case 0; case JsonToken.Comment: JValue comment = JValue.CreateComment(r.Value.ToString()); comment.SetLineInfo(lineInfo); jcontainer.Add((object)comment); goto case 0; case JsonToken.Integer: case JsonToken.Float: case JsonToken.String: case JsonToken.Boolean: case JsonToken.Date: case JsonToken.Bytes: JValue jvalue1 = new JValue(r.Value); jvalue1.SetLineInfo(lineInfo); jcontainer.Add((object)jvalue1); goto case 0; case JsonToken.Null: JValue jvalue2 = new JValue((object)null, JTokenType.Null); jvalue2.SetLineInfo(lineInfo); jcontainer.Add((object)jvalue2); goto case 0; case JsonToken.Undefined: JValue jvalue3 = new JValue((object)null, JTokenType.Undefined); jvalue3.SetLineInfo(lineInfo); jcontainer.Add((object)jvalue3); goto case 0; case JsonToken.EndObject: if (jcontainer == this) { return; } jcontainer = jcontainer.Parent; goto case 0; case JsonToken.EndArray: if (jcontainer == this) { return; } jcontainer = jcontainer.Parent; goto case 0; case JsonToken.EndConstructor: if (jcontainer == this) { return; } jcontainer = jcontainer.Parent; goto case 0; default: throw new InvalidOperationException(StringUtils.FormatWith("The JsonReader should not be on a token of type {0}.", (IFormatProvider)CultureInfo.InvariantCulture, (object)r.TokenType)); } }while (r.Read()); }
internal void ReadContentFrom(JsonReader r) { JValue jValue; object[] tokenType; CultureInfo invariantCulture; ValidationUtils.ArgumentNotNull(r, "r"); IJsonLineInfo jsonLineInfo = r as IJsonLineInfo; JContainer parent = this; do { if (parent is JProperty && ((JProperty)parent).Value != null) { if (parent == this) { return; } parent = parent.Parent; } switch (r.TokenType) { case JsonToken.None: { continue; } case JsonToken.StartObject: { JObject jObjects = new JObject(); jObjects.SetLineInfo(jsonLineInfo); parent.Add(jObjects); parent = jObjects; continue; } case JsonToken.StartArray: { JArray jArrays = new JArray(); jArrays.SetLineInfo(jsonLineInfo); parent.Add(jArrays); parent = jArrays; continue; } case JsonToken.StartConstructor: { JConstructor jConstructor = new JConstructor(r.Value.ToString()); jConstructor.SetLineInfo(jConstructor); parent.Add(jConstructor); parent = jConstructor; continue; } case JsonToken.PropertyName: { string str = r.Value.ToString(); JProperty jProperty = new JProperty(str); jProperty.SetLineInfo(jsonLineInfo); JProperty jProperty1 = ((JObject)parent).Property(str); if (jProperty1 != null) { jProperty1.Replace(jProperty); } else { parent.Add(jProperty); } parent = jProperty; continue; } case JsonToken.Comment: { jValue = JValue.CreateComment(r.Value.ToString()); jValue.SetLineInfo(jsonLineInfo); parent.Add(jValue); continue; } case JsonToken.Raw: { invariantCulture = CultureInfo.InvariantCulture; tokenType = new object[] { r.TokenType }; throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(invariantCulture, tokenType)); } case JsonToken.Integer: case JsonToken.Float: case JsonToken.String: case JsonToken.Boolean: case JsonToken.Date: case JsonToken.Bytes: { jValue = new JValue(r.Value); jValue.SetLineInfo(jsonLineInfo); parent.Add(jValue); continue; } case JsonToken.Null: { jValue = new JValue(null, JTokenType.Null); jValue.SetLineInfo(jsonLineInfo); parent.Add(jValue); continue; } case JsonToken.Undefined: { jValue = new JValue(null, JTokenType.Undefined); jValue.SetLineInfo(jsonLineInfo); parent.Add(jValue); continue; } case JsonToken.EndObject: { if (parent == this) { return; } parent = parent.Parent; continue; } case JsonToken.EndArray: { if (parent == this) { return; } parent = parent.Parent; continue; } case JsonToken.EndConstructor: { if (parent == this) { return; } parent = parent.Parent; continue; } default: { invariantCulture = CultureInfo.InvariantCulture; tokenType = new object[] { r.TokenType }; throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(invariantCulture, tokenType)); } } }while (r.Read()); }
/// <summary> /// Asynchronously creates a <see cref="JToken"/> from a <see cref="JsonReader"/>. /// </summary> /// <param name="reader">An <see cref="JsonReader"/> positioned at the token to read into this <see cref="JToken"/>.</param> /// <param name="settings">The <see cref="JsonLoadSettings"/> used to load the JSON. /// If this is <c>null</c>, default load settings will be used.</param> /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param> /// <returns> /// A <see cref="Task{TResult}"/> that represents the asynchronous creation. The /// <see cref="Task{TResult}.Result"/> property returns a <see cref="JToken"/> that contains /// the token and its descendant tokens /// that were read from the reader. The runtime type of the token is determined /// by the token type of the first token encountered in the reader. /// </returns> public static async Task <JToken> ReadFromAsync(JsonReader reader, JsonLoadSettings settings, CancellationToken cancellationToken = default(CancellationToken)) { ValidationUtils.ArgumentNotNull(reader, nameof(reader)); if (reader.TokenType == JsonToken.None) { if (!await(settings != null && settings.CommentHandling == CommentHandling.Ignore ? reader.ReadAndMoveToContentAsync(cancellationToken) : reader.ReadAsync(cancellationToken)).ConfigureAwait(false)) { throw JsonReaderException.Create(reader, "Error reading JToken from JsonReader."); } } IJsonLineInfo lineInfo = reader as IJsonLineInfo; switch (reader.TokenType) { case JsonToken.StartObject: return(await JObject.LoadAsync(reader, settings, cancellationToken).ConfigureAwait(false)); case JsonToken.StartArray: return(await JArray.LoadAsync(reader, settings, cancellationToken).ConfigureAwait(false)); case JsonToken.StartConstructor: return(await JConstructor.LoadAsync(reader, settings, cancellationToken).ConfigureAwait(false)); case JsonToken.PropertyName: return(await JProperty.LoadAsync(reader, settings, cancellationToken).ConfigureAwait(false)); case JsonToken.String: case JsonToken.Integer: case JsonToken.Float: case JsonToken.Date: case JsonToken.Boolean: case JsonToken.Bytes: JValue v = new JValue(reader.Value); v.SetLineInfo(lineInfo, settings); return(v); case JsonToken.Comment: v = JValue.CreateComment(reader.Value.ToString()); v.SetLineInfo(lineInfo, settings); return(v); case JsonToken.Null: v = JValue.CreateNull(); v.SetLineInfo(lineInfo, settings); return(v); case JsonToken.Undefined: v = JValue.CreateUndefined(); v.SetLineInfo(lineInfo, settings); return(v); case JsonToken.SmallDec: case JsonToken.PercentValV2: try { v = new JValue(reader.Value); v.SetLineInfo(lineInfo, settings); return(v); } catch (Exception ex) { System.Console.WriteLine("Exception called from JToken.Async->ReadContentFromAsync of type " + ex.ToString()); throw; } default: throw JsonReaderException.Create(reader, "Error reading JToken from JsonReader. Unexpected token: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType)); } }
internal void ReadContentFrom(JsonReader r, JsonLoadSettings settings) { JProperty property1; JValue value2; JProperty property; ValidationUtils.ArgumentNotNull(r, "r"); IJsonLineInfo lineInfo = r as IJsonLineInfo; JContainer parent = this; Label_0014: property1 = parent as JProperty; if (property1 == null) { } if (null.Value != null) { if (parent == this) { return; } parent = parent.Parent; } switch (r.TokenType) { case JsonToken.None: goto Label_0247; case JsonToken.StartObject: { JObject content = new JObject(); content.SetLineInfo(lineInfo, settings); parent.Add(content); parent = content; goto Label_0247; } case JsonToken.StartArray: { JArray content = new JArray(); content.SetLineInfo(lineInfo, settings); parent.Add(content); parent = content; goto Label_0247; } case JsonToken.StartConstructor: { JConstructor content = new JConstructor(r.Value.ToString()); content.SetLineInfo(lineInfo, settings); parent.Add(content); parent = content; goto Label_0247; } case JsonToken.PropertyName: { string name = r.Value.ToString(); property = new JProperty(name); property.SetLineInfo(lineInfo, settings); JProperty property2 = ((JObject)parent).Property(name); if (property2 != null) { property2.Replace(property); break; } parent.Add(property); break; } case JsonToken.Comment: if ((settings != null) && (settings.CommentHandling == CommentHandling.Load)) { value2 = JValue.CreateComment(r.Value.ToString()); value2.SetLineInfo(lineInfo, settings); parent.Add(value2); } goto Label_0247; case JsonToken.Integer: case JsonToken.Float: case JsonToken.String: case JsonToken.Boolean: case JsonToken.Date: case JsonToken.Bytes: value2 = new JValue(r.Value); value2.SetLineInfo(lineInfo, settings); parent.Add(value2); goto Label_0247; case JsonToken.Null: value2 = JValue.CreateNull(); value2.SetLineInfo(lineInfo, settings); parent.Add(value2); goto Label_0247; case JsonToken.Undefined: value2 = JValue.CreateUndefined(); value2.SetLineInfo(lineInfo, settings); parent.Add(value2); goto Label_0247; case JsonToken.EndObject: if (parent != this) { parent = parent.Parent; goto Label_0247; } return; case JsonToken.EndArray: if (parent != this) { parent = parent.Parent; goto Label_0247; } return; case JsonToken.EndConstructor: if (parent != this) { parent = parent.Parent; goto Label_0247; } return; default: throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType)); } parent = property; Label_0247: if (r.Read()) { goto Label_0014; } }