Ejemplo n.º 1
0
        private SmileType ReadType()
        {
            SmileType type = SmileType.Parse(_reader.ReadByte());

            //System.Diagnostics.Debug.WriteLine("	propertyType: {0}, {1}, {2}", (byte)type.TypeClass, type.Value, type.TypeClass);
            return(type);
        }
Ejemplo n.º 2
0
        private bool ReadNormal()
        {
            switch (CurrentState)
            {
            case State.Start:
            {
                JsonToken token = (!_readRootValueAsArray) ? JsonToken.StartObject : JsonToken.StartArray;
                SmileType type  = (!_readRootValueAsArray) ? SmileType.NewObject() : SmileType.NewArray();

                _currentElementType = ReadType();
                type = _currentElementType;

                SetToken(token);
                PushContext(type);
                return(true);
            }

            case State.Complete:
            case State.Closed:
                return(false);

            case State.Property:
            {
                ReadType(_currentElementType);
                return(true);
            }

            case State.ObjectStart:
            case State.ArrayStart:
            case State.PostValue:
            {
                SmileType context = _currentContext;
                if (context == null)
                {
                    return(false);
                }

                byte keyType = this.ReadByte();
                if (keyType == (byte)0xF9 || keyType == (byte)0xFB)
                {
                    PopContext();
                    JsonToken endToken = (context.TypeClass == SmileTypeClass.START_OBJECT) ? JsonToken.EndObject : JsonToken.EndArray;
                    SetToken(endToken);
                    return(true);
                }

                if (_currentContext.TypeClass == SmileTypeClass.START_ARRAY)
                {
                    _currentElementType = SmileType.Parse(keyType);
                    ReadType(_currentElementType);
                }
                else
                {
                    SetToken(JsonToken.PropertyName, ReadElement(keyType));
                }

                return(true);
            }

            case State.ConstructorStart:
                break;

            case State.Constructor:
                break;

            case State.Error:
                break;

            case State.Finished:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(false);
        }