// Token: 0x06000C19 RID: 3097 RVA: 0x0004FEA0 File Offset: 0x0004E0A0 protected void SetStateBasedOnCurrent() { JsonContainerType jsonContainerType = this.Peek(); switch (jsonContainerType) { case JsonContainerType.None: this.SetFinished(); return; case JsonContainerType.Object: this._currentState = JsonReader.State.Object; return; case JsonContainerType.Array: this._currentState = JsonReader.State.Array; return; case JsonContainerType.Constructor: this._currentState = JsonReader.State.Constructor; return; default: throw JsonReaderException.Create(this, "While setting the reader state back to current object an unexpected JsonType was encountered: {0}".FormatWith(CultureInfo.InvariantCulture, jsonContainerType)); } }
internal void WriteTo(StringBuilder sb, ref StringWriter writer, ref char[] buffer) { JsonContainerType type = this.Type; if (type != JsonContainerType.Object) { if ((int)type - (int)JsonContainerType.Array > (int)JsonContainerType.Object) { return; } sb.Append('['); sb.Append(this.Position); sb.Append(']'); return; } string propertyName = this.PropertyName; if (propertyName.IndexOfAny(JsonPosition.SpecialCharacters) == -1) { if (sb.Length > 0) { sb.Append('.'); } sb.Append(propertyName); return; } sb.Append("['"); if (writer == null) { writer = new StringWriter(sb); } JavaScriptUtils.WriteEscapedJavaScriptString(writer, propertyName, '\'', false, JavaScriptUtils.SingleQuoteCharEscapeFlags, StringEscapeHandling.Default, null, ref buffer); sb.Append("']"); }
private void Push(JsonContainerType value) { UpdateScopeWithFinishedValue(); if (_currentPosition.Type == JsonContainerType.None) { _currentPosition = new JsonPosition(value); } else { if (_stack == null) { _stack = new List <JsonPosition>(); } _stack.Add(_currentPosition); _currentPosition = new JsonPosition(value); // this is a little hacky because Depth increases when first property/value is written but only testing here is faster/simpler if (_maxDepth != null && Depth + 1 > _maxDepth && !_hasExceededMaxDepth) { _hasExceededMaxDepth = true; throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, _maxDepth)); } } }
/// <summary> /// Sets the state based on current token type. /// </summary> protected void SetStateBasedOnCurrent() { JsonContainerType currentObject = Peek(); switch (currentObject) { case JsonContainerType.Object: _currentState = State.Object; break; case JsonContainerType.Array: _currentState = State.Array; break; case JsonContainerType.Constructor: _currentState = State.Constructor; break; case JsonContainerType.None: SetFinished(); break; default: throw JsonReaderException.Create(this, "While setting the reader state back to current object an unexpected JsonType was encountered: {0}".FormatWith(CultureInfo.InvariantCulture, currentObject)); } }
public JsonPosition(JsonContainerType type) { Type = type; HasIndex = TypeHasIndex(type); Position = -1; PropertyName = null; }
// Token: 0x06000A52 RID: 2642 RVA: 0x0003ECC4 File Offset: 0x0003CEC4 public JsonPosition(JsonContainerType type) { this.Type = type; this.HasIndex = JsonPosition.TypeHasIndex(type); this.Position = -1; this.PropertyName = null; }
protected void SetStateBasedOnCurrent() { JsonContainerType jsonContainerType = this.Peek(); switch (jsonContainerType) { case JsonContainerType.None: this._currentState = JsonReader.State.Finished; break; case JsonContainerType.Object: this._currentState = JsonReader.State.Object; break; case JsonContainerType.Array: this._currentState = JsonReader.State.Array; break; case JsonContainerType.Constructor: this._currentState = JsonReader.State.Constructor; break; default: throw JsonReaderException.Create(this, StringUtils.FormatWith("While setting the reader state back to current object an unexpected JsonType was encountered: {0}", (IFormatProvider)CultureInfo.InvariantCulture, (object)jsonContainerType)); } }
// Token: 0x06000BFB RID: 3067 RVA: 0x0004F018 File Offset: 0x0004D218 private void Push(JsonContainerType value) { this.UpdateScopeWithFinishedValue(); if (this._currentPosition.Type == JsonContainerType.None) { this._currentPosition = new JsonPosition(value); return; } if (this._stack == null) { this._stack = new List <JsonPosition>(); } this._stack.Add(this._currentPosition); this._currentPosition = new JsonPosition(value); if (this._maxDepth != null) { int num = this.Depth + 1; int?maxDepth = this._maxDepth; if ((num > maxDepth.GetValueOrDefault() & maxDepth != null) && !this._hasExceededMaxDepth) { this._hasExceededMaxDepth = true; throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, this._maxDepth)); } } }
private void Push(JsonContainerType value) { this.UpdateScopeWithFinishedValue(); if (this._currentPosition.Type == JsonContainerType.None) { this._currentPosition.Type = value; } else { this._stack.Add(this._currentPosition); this._currentPosition = new JsonPosition() { Type = value }; if (!this._maxDepth.HasValue) { return; } int num = this.Depth + 1; int?nullable = this._maxDepth; if ((num <= nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) == 0 || this._hasExceededMaxDepth) { return; } this._hasExceededMaxDepth = true; throw JsonReaderException.Create(this, StringUtils.FormatWith("The reader's MaxDepth of {0} has been exceeded.", (IFormatProvider)CultureInfo.InvariantCulture, (object)this._maxDepth)); } }
public JsonPosition(JsonContainerType type) { Class6.yDnXvgqzyB5jw(); this.Type = type; this.HasIndex = JsonPosition.TypeHasIndex(type); this.Position = -1; this.PropertyName = null; }
private static JsonNode GetContainer(JsonContainerType aType) { if (aType == JsonContainerType.Array) { return(new JSONArray()); } return(new JSONObject()); }
private void Push(JsonContainerType value) { if (this._currentPosition.Type != JsonContainerType.None) { this._stack.Add(this._currentPosition); } this._currentPosition = new JsonPosition(value); }
internal static bool TypeHasIndex(JsonContainerType type) { if (type != JsonContainerType.Array) { return(type == JsonContainerType.Constructor); } return(true); }
private void ValidateEnd(JsonToken endToken) { JsonContainerType currentObject = Pop(); if (GetTypeForCloseToken(endToken) != currentObject) throw JsonReaderException.Create(this, "JsonToken {0} is not valid for closing JsonType {1}.".FormatWith(CultureInfo.InvariantCulture, endToken, currentObject)); _currentState = (Peek() != JsonContainerType.None) ? State.PostValue : State.Finished; }
private void ValidateEnd(JsonToken endToken) { JsonContainerType jsonContainerType = this.Pop(); if (this.GetTypeForCloseToken(endToken) != jsonContainerType) { throw JsonReaderException.Create(this, StringUtils.FormatWith("JsonToken {0} is not valid for closing JsonType {1}.", (IFormatProvider)CultureInfo.InvariantCulture, (object)endToken, (object)jsonContainerType)); } this._currentState = this.Peek() != JsonContainerType.None ? JsonReader.State.PostValue : JsonReader.State.Finished; }
// Token: 0x06000BB9 RID: 3001 RVA: 0x0004ECCC File Offset: 0x0004CECC internal int CalculateLength() { JsonContainerType type = this.Type; if (type == JsonContainerType.Object) { return(this.PropertyName.Length + 5); } if (type - JsonContainerType.Array > 1) { throw new ArgumentOutOfRangeException("Type"); } return(MathUtils.IntLength((ulong)((long)this.Position)) + 2); }
private void Push(JsonContainerType value) { if (this._currentPosition.Type == JsonContainerType.None) { this._currentPosition.Type = value; } else { this._stack.Add(this._currentPosition); this._currentPosition = new JsonPosition() { Type = value }; } }
private JsonToken GetCloseTokenForType(JsonContainerType type) { switch (type) { case JsonContainerType.Object: return(JsonToken.EndObject); case JsonContainerType.Array: return(JsonToken.EndArray); case JsonContainerType.Constructor: return(JsonToken.EndConstructor); } throw JsonWriterException.Create(this, "No close token for type: " + type, null); }
private void ValidateEnd(JsonToken endToken) { JsonContainerType jsonContainerType = this.Pop(); if (this.GetTypeForCloseToken(endToken) != jsonContainerType) { throw JsonReaderException.Create(this, "JsonToken {0} is not valid for closing JsonType {1}.".FormatWith(CultureInfo.InvariantCulture, endToken, jsonContainerType)); } if (this.Peek() != JsonContainerType.None) { this._currentState = JsonReader.State.PostValue; return; } this.SetFinished(); }
private void Push(JsonContainerType value) { this.UpdateScopeWithFinishedValue(); if (this._currentPosition.Type == JsonContainerType.None) { this._currentPosition = new JsonPosition(value); return; } this._stack.Add(this._currentPosition); this._currentPosition = new JsonPosition(value); if (this._maxDepth.HasValue && this.Depth + 1 > this._maxDepth && !this._hasExceededMaxDepth) { this._hasExceededMaxDepth = true; throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, this._maxDepth)); } }
private void Push(JsonContainerType value) { if (_currentPosition.Type == JsonContainerType.None) { _currentPosition.Type = value; } else { _stack.Add(_currentPosition); var state = new JsonPosition { Type = value }; _currentPosition = state; } }
private JsonToken GetCloseTokenForType(JsonContainerType type) { switch (type) { case JsonContainerType.Object: return(JsonToken.EndObject); case JsonContainerType.Array: return(JsonToken.EndArray); case JsonContainerType.Constructor: return(JsonToken.EndConstructor); default: throw new JsonWriterException("No close token for type: " + type); } }
private void WriteEnd(JsonContainerType type) { switch (type) { case JsonContainerType.Object: this.WriteEndObject(); return; case JsonContainerType.Array: this.WriteEndArray(); return; case JsonContainerType.Constructor: this.WriteEndConstructor(); return; } throw JsonWriterException.Create(this, "Unexpected type when writing end: " + type, null); }
private void ValidateEnd(JsonToken endToken) { JsonContainerType currentObject = Pop(); if (GetTypeForCloseToken(endToken) != currentObject) { throw JsonReaderException.Create(this, string.Format("JsonToken {0} is not valid for closing JsonType {1}.", endToken, currentObject)); } if (Peek() != JsonContainerType.None) { _currentState = State.PostValue; } else { SetFinished(); } }
private void Push(JsonContainerType value) { UpdateScopeWithFinishedValue(); if (_currentPosition.Type == JsonContainerType.None) { _currentPosition.Type = value; } else { _stack.Add(_currentPosition); var state = new JsonPosition { Type = value }; _currentPosition = state; } }
private void ValidateEnd(JsonToken endToken) { JsonContainerType currentObject = Pop(); if (GetTypeForCloseToken(endToken) != currentObject) { throw JsonReaderException.Create(this, "JsonToken {0} is not valid for closing JsonType {1}.".FormatWith(CultureInfo.InvariantCulture, endToken, currentObject)); } if (Peek() != JsonContainerType.None || SupportMultipleContent) { _currentState = State.PostValue; } else { SetFinished(); } }
private void AutoCompleteClose(JsonContainerType type) { int levelsToComplete = this.CalculateLevelsToComplete(type); for (int index = 0; index < levelsToComplete; ++index) { JsonToken closeTokenForType = this.GetCloseTokenForType(this.Pop()); if (this._currentState == JsonWriter.State.Property) { this.WriteNull(); } if (this._formatting == Formatting.Indented && this._currentState != JsonWriter.State.ObjectStart && this._currentState != JsonWriter.State.ArrayStart) { this.WriteIndent(); } this.WriteEnd(closeTokenForType); this.UpdateCurrentState(); } }
private void WriteEnd(JsonContainerType type) { switch (type) { case JsonContainerType.Object: this.WriteEndObject(); break; case JsonContainerType.Array: this.WriteEndArray(); break; case JsonContainerType.Constructor: this.WriteEndConstructor(); break; default: throw JsonWriterException.Create(this, "Unexpected type when writing end: " + (object)type, (Exception)null); } }
private void WriteEnd(JsonContainerType type) { switch (type) { case JsonContainerType.Object: WriteEndObject(); break; case JsonContainerType.Array: WriteEndArray(); break; case JsonContainerType.Constructor: WriteEndConstructor(); break; default: throw new JsonWriterException("Unexpected type when writing end: " + type); } }
internal static bool TypeHasIndex(JsonContainerType type) { return (type == JsonContainerType.Array || type == JsonContainerType.Constructor); }
// Token: 0x06000074 RID: 116 // RVA: 0x00028D14 File Offset: 0x00026F14 private void Push(JsonContainerType value) { this.UpdateScopeWithFinishedValue(); if (this._currentPosition.Type == JsonContainerType.None) { this._currentPosition = new JsonPosition(value); return; } this._stack.Add(this._currentPosition); this._currentPosition = new JsonPosition(value); if (this._maxDepth.HasValue && this.Depth + 1 > this._maxDepth && !this._hasExceededMaxDepth) { this._hasExceededMaxDepth = true; throw JsonReaderException.Create(this, StringUtils.FormatWith("The reader's MaxDepth of {0} has been exceeded.", CultureInfo.InvariantCulture, this._maxDepth)); } }
internal void InternalWriteStart(JsonToken token, JsonContainerType container) { this.UpdateScopeWithFinishedValue(); this.AutoComplete(token); this.Push(container); }
private void Push(JsonContainerType value) { UpdateScopeWithFinishedValue(); if (_currentPosition.Type == JsonContainerType.None) { _currentPosition = new JsonPosition(value); } else { _stack.Add(_currentPosition); _currentPosition = new JsonPosition(value); // this is a little hacky because Depth increases when first property/value is written but only testing here is faster/simpler if (_maxDepth != null && Depth + 1 > _maxDepth && !_hasExceededMaxDepth) { _hasExceededMaxDepth = true; throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, _maxDepth)); } } }
private void Push(JsonContainerType value) { if (_currentPosition.Type != JsonContainerType.None) { if (_stack == null) { _stack = new List<JsonPosition>(); } _stack.Add(_currentPosition); } _currentPosition = new JsonPosition(value); }
private JsonToken GetCloseTokenForType(JsonContainerType type) { switch (type) { case JsonContainerType.Object: return JsonToken.EndObject; case JsonContainerType.Array: return JsonToken.EndArray; case JsonContainerType.Constructor: return JsonToken.EndConstructor; default: throw JsonWriterException.Create(this, "No close token for type: " + type, null); } }
private void Push(JsonContainerType value) { this.UpdateScopeWithFinishedValue(); if (this._currentPosition.Type == JsonContainerType.None) { this._currentPosition.Type = value; } else { this._stack.Add(this._currentPosition); this._currentPosition = new JsonPosition() { Type = value }; if (!this._maxDepth.HasValue) return; int num = this.Depth + 1; int? nullable = this._maxDepth; if ((num <= nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) == 0 || this._hasExceededMaxDepth) return; this._hasExceededMaxDepth = true; throw JsonReaderException.Create(this, StringUtils.FormatWith("The reader's MaxDepth of {0} has been exceeded.", (IFormatProvider) CultureInfo.InvariantCulture, (object) this._maxDepth)); } }
private void Push(JsonContainerType value) { if (_currentPosition.Type != JsonContainerType.None) _stack.Add(_currentPosition); _currentPosition = new JsonPosition(value); }
internal void InternalWriteEnd(JsonContainerType container) { AutoCompleteClose(container); }
internal void InternalWriteStart(JsonToken token, JsonContainerType container) { UpdateScopeWithFinishedValue(); AutoComplete(token); Push(container); }
private void AutoCompleteClose(JsonContainerType type) { int num1 = 0; if (this._currentPosition.Type == type) { num1 = 1; } else { int num2 = this.Top - 2; for (int index = num2; index >= 0; --index) { if (this._stack[num2 - index].Type == type) { num1 = index + 2; break; } } } if (num1 == 0) throw JsonWriterException.Create(this, "No token to close.", (Exception) null); for (int index = 0; index < num1; ++index) { JsonToken closeTokenForType = this.GetCloseTokenForType(this.Pop()); if (this._currentState == JsonWriter.State.Property) this.WriteNull(); if (this._formatting == Formatting.Indented && this._currentState != JsonWriter.State.ObjectStart && this._currentState != JsonWriter.State.ArrayStart) this.WriteIndent(); this.WriteEnd(closeTokenForType); JsonContainerType jsonContainerType = this.Peek(); switch (jsonContainerType) { case JsonContainerType.None: this._currentState = JsonWriter.State.Start; break; case JsonContainerType.Object: this._currentState = JsonWriter.State.Object; break; case JsonContainerType.Array: this._currentState = JsonWriter.State.Array; break; case JsonContainerType.Constructor: this._currentState = JsonWriter.State.Array; break; default: throw JsonWriterException.Create(this, "Unknown JsonType: " + (object) jsonContainerType, (Exception) null); } } }
private void WriteEnd(JsonContainerType type) { switch (type) { case JsonContainerType.Object: WriteEndObject(); break; case JsonContainerType.Array: WriteEndArray(); break; case JsonContainerType.Constructor: WriteEndConstructor(); break; default: throw JsonWriterException.Create(this, "Unexpected type when writing end: " + type, null); } }
private void AutoCompleteClose(JsonContainerType type) { // write closing symbol and calculate new state int levelsToComplete = 0; if (_currentPosition.Type == type) { levelsToComplete = 1; } else { int top = Top - 2; for (int i = top; i >= 0; i--) { int currentLevel = top - i; if (_stack[currentLevel].Type == type) { levelsToComplete = i + 2; break; } } } if (levelsToComplete == 0) throw JsonWriterException.Create(this, "No token to close.", null); for (int i = 0; i < levelsToComplete; i++) { JsonToken token = GetCloseTokenForType(Pop()); if (_currentState == State.Property) WriteNull(); if (_formatting == Formatting.Indented) { if (_currentState != State.ObjectStart && _currentState != State.ArrayStart) WriteIndent(); } WriteEnd(token); JsonContainerType currentLevelType = Peek(); switch (currentLevelType) { case JsonContainerType.Object: _currentState = State.Object; break; case JsonContainerType.Array: _currentState = State.Array; break; case JsonContainerType.Constructor: _currentState = State.Array; break; case JsonContainerType.None: _currentState = State.Start; break; default: throw JsonWriterException.Create(this, "Unknown JsonType: " + currentLevelType, null); } } }