Esempio n. 1
0
        // 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));
            }
        }
Esempio n. 2
0
        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("']");
        }
Esempio n. 3
0
        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));
                }
            }
        }
Esempio n. 4
0
        /// <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));
            }
        }
Esempio n. 5
0
 public JsonPosition(JsonContainerType type)
 {
     Type         = type;
     HasIndex     = TypeHasIndex(type);
     Position     = -1;
     PropertyName = null;
 }
Esempio n. 6
0
 // 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;
 }
Esempio n. 7
0
 public JsonPosition(JsonContainerType type)
 {
     Type = type;
     HasIndex = TypeHasIndex(type);
     Position = -1;
     PropertyName = null;
 }
Esempio n. 8
0
        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));
            }
        }
Esempio n. 9
0
 // 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));
         }
     }
 }
Esempio n. 10
0
 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));
     }
 }
Esempio n. 11
0
 public JsonPosition(JsonContainerType type)
 {
     Class6.yDnXvgqzyB5jw();
     this.Type         = type;
     this.HasIndex     = JsonPosition.TypeHasIndex(type);
     this.Position     = -1;
     this.PropertyName = null;
 }
Esempio n. 12
0
 private static JsonNode GetContainer(JsonContainerType aType)
 {
     if (aType == JsonContainerType.Array)
     {
         return(new JSONArray());
     }
     return(new JSONObject());
 }
Esempio n. 13
0
 private void Push(JsonContainerType value)
 {
     if (this._currentPosition.Type != JsonContainerType.None)
     {
         this._stack.Add(this._currentPosition);
     }
     this._currentPosition = new JsonPosition(value);
 }
Esempio n. 14
0
 internal static bool TypeHasIndex(JsonContainerType type)
 {
     if (type != JsonContainerType.Array)
     {
         return(type == JsonContainerType.Constructor);
     }
     return(true);
 }
Esempio n. 15
0
    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;
    }
Esempio n. 16
0
        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;
        }
Esempio n. 17
0
        // 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);
        }
Esempio n. 18
0
 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
         };
     }
 }
Esempio n. 19
0
        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);
        }
Esempio n. 20
0
        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();
        }
Esempio n. 21
0
 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));
     }
 }
Esempio n. 22
0
 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;
     }
 }
Esempio n. 23
0
        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);
            }
        }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        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();
            }
        }
Esempio n. 26
0
        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;
            }
        }
Esempio n. 27
0
        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();
            }
        }
Esempio n. 28
0
        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();
            }
        }
Esempio n. 29
0
        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);
            }
        }
Esempio n. 30
0
        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);
            }
        }
Esempio n. 31
0
 internal static bool TypeHasIndex(JsonContainerType type)
 {
     return (type == JsonContainerType.Array || type == JsonContainerType.Constructor);
 }
Esempio n. 32
0
 // 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));
     }
 }
Esempio n. 33
0
 internal void InternalWriteStart(JsonToken token, JsonContainerType container)
 {
     this.UpdateScopeWithFinishedValue();
     this.AutoComplete(token);
     this.Push(container);
 }
Esempio n. 34
0
        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));
                }
            }
        }
Esempio n. 35
0
        private void Push(JsonContainerType value)
        {
            if (_currentPosition.Type != JsonContainerType.None)
            {
                if (_stack == null)
                {
                    _stack = new List<JsonPosition>();
                }

                _stack.Add(_currentPosition);
            }

            _currentPosition = new JsonPosition(value);
        }
Esempio n. 36
0
 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);
     }
 }
Esempio n. 37
0
 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));
   }
 }
Esempio n. 38
0
        private void Push(JsonContainerType value)
        {
            if (_currentPosition.Type != JsonContainerType.None)
                _stack.Add(_currentPosition);

            _currentPosition = new JsonPosition(value);
        }
Esempio n. 39
0
 internal void InternalWriteEnd(JsonContainerType container)
 {
     AutoCompleteClose(container);
 }
Esempio n. 40
0
    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;
      }
    }
Esempio n. 41
0
 internal void InternalWriteStart(JsonToken token, JsonContainerType container)
 {
     UpdateScopeWithFinishedValue();
     AutoComplete(token);
     Push(container);
 }
Esempio n. 42
0
 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);
     }
   }
 }
Esempio n. 43
0
 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);
     }
 }
Esempio n. 44
0
 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;
   }
 }
Esempio n. 45
0
        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);
                }
            }
        }
Esempio n. 46
0
 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
     };
   }
 }