Exemplo n.º 1
0
        public object ReadNextObject()
        {
            int b = stream.ReadByte();

            if (b < 0)
            {
                throw new EndOfStreamException();
            }

            Amf3TypeCode type = (Amf3TypeCode)b;

            switch (type)
            {
            case Amf3TypeCode.Undefined:
            case Amf3TypeCode.Null:
                return(null);

            case Amf3TypeCode.False:
                return(false);

            case Amf3TypeCode.True:
                return(true);

            case Amf3TypeCode.Integer:
                return(ReadInteger());

            case Amf3TypeCode.Number:
                return(ReadNumber());

            case Amf3TypeCode.String:
                return(ReadString());

            case Amf3TypeCode.Date:
                return(ReadDate());

            case Amf3TypeCode.Array:
                return(ReadArray());

            case Amf3TypeCode.Object:
                return(ReadAmf3Object());

            case Amf3TypeCode.ByteArray:
                return(ReadByteArray());

            case Amf3TypeCode.VectorInt:
                return(ReadVectorInt());

            case Amf3TypeCode.VectorUInt:
                return(ReadVectorUInt());

            case Amf3TypeCode.VectorDouble:
                return(ReadVectorDouble());

            case Amf3TypeCode.VectorObject:
            case Amf3TypeCode.Dictionary:
            default:
                throw new NotImplementedException("Cannot parse type " + type.ToString());
            }
        }
Exemplo n.º 2
0
        public object ReadNextObject()
        {
            int b = stream.ReadByte();

            if (b < 0)
            {
                throw new EndOfStreamException();
            }

            Amf3TypeCode type = (Amf3TypeCode)b;

            switch (type)
            {
            case Amf3TypeCode.Undefined:
            case Amf3TypeCode.Null:
                return(null);

            case Amf3TypeCode.False:
                return(false);

            case Amf3TypeCode.True:
                return(true);

            case Amf3TypeCode.Integer:
                return(ReadInteger());

            case Amf3TypeCode.Number:
                return(ReadNumber());

            case Amf3TypeCode.String:
                return(ReadString());

            case Amf3TypeCode.Date:
                return(ReadDate());

            case Amf3TypeCode.Array:
                return(ReadArray());

            case Amf3TypeCode.Object:
                return(ReadAmf3Object());
            }

            throw new InvalidOperationException("Cannot parse type " + type.ToString());
        }
Exemplo n.º 3
0
 private void Write(Amf3TypeCode type)
 {
     Stream.WriteByte((byte)type);
 }
Exemplo n.º 4
0
        // this read the next object into a value structure
        // this avoids unnecessary boxing/unboxing of value types and speeds up deserialization
        public void ReadNextObject(ref Variant value)
        {
            byte         b    = ReadByte();
            Amf3TypeCode type = (Amf3TypeCode)b;

            switch (type)
            {
            case Amf3TypeCode.Undefined:
                value = Variant.Undefined;
                return;

            case Amf3TypeCode.Null:
                value = Variant.Null;
                return;

            case Amf3TypeCode.False:
                value = false;
                return;

            case Amf3TypeCode.True:
                value = true;
                return;

            case Amf3TypeCode.Integer:
                value = ReadInteger();
                break;

            case Amf3TypeCode.Number:
                value = ReadNumber();
                break;

            case Amf3TypeCode.String:
                value = ReadString();
                break;

            case Amf3TypeCode.Date:
                value = new Variant(ReadDate());
                break;

            case Amf3TypeCode.Array:
                value = new Variant(ReadArray());
                break;

            case Amf3TypeCode.Object:
                value = new Variant(ReadAmf3Object());
                break;

            case Amf3TypeCode.ByteArray:
                value = new Variant(ReadByteArray());
                break;

            case Amf3TypeCode.VectorInt:
                value = new Variant(ReadVectorInt());
                break;

            case Amf3TypeCode.VectorUInt:
                value = new Variant(ReadVectorUInt());
                break;

            case Amf3TypeCode.VectorDouble:
                value = new Variant(ReadVectorDouble());
                break;

            case Amf3TypeCode.Dictionary:
                value = new Variant(ReadDictionary());
                break;

            case Amf3TypeCode.VectorObject:
                value = new Variant(ReadVectorObject());
                break;

            default:
                throw new NotImplementedException("Cannot parse type " + type.ToString());
            }
        }
Exemplo n.º 5
0
        public object ReadNextObject()
        {
            byte b = ReadByte();

            Amf3TypeCode type = (Amf3TypeCode)b;

            switch (type)
            {
            case Amf3TypeCode.Undefined:
            case Amf3TypeCode.Null:
                return(null);

            case Amf3TypeCode.False:
                return(sBoolFalse);

            case Amf3TypeCode.True:
                return(sBoolTrue);

            case Amf3TypeCode.Integer:
            {
                int i = ReadInteger();
                if (i == 0)
                {
                    return(sIntZero);
                }
                if (i == 1)
                {
                    return(sIntOne);
                }
                if (i == -1)
                {
                    return(sIntNegOne);
                }
                return((object)i);
            }

            case Amf3TypeCode.Number:
            {
                double d = ReadNumber();
                if (d == 0.0)
                {
                    return(sNumberZero);
                }
                if (d == 1.0)
                {
                    return(sNumberOne);
                }
                return((object)d);
            }

            case Amf3TypeCode.String:
                return(ReadString());

            case Amf3TypeCode.Date:
                return(ReadDate());

            case Amf3TypeCode.Array:
                return(ReadArray());

            case Amf3TypeCode.Object:
                return(ReadAmf3Object());

            case Amf3TypeCode.ByteArray:
                return(ReadByteArray());

            case Amf3TypeCode.VectorInt:
                return(ReadVectorInt());

            case Amf3TypeCode.VectorUInt:
                return(ReadVectorUInt());

            case Amf3TypeCode.VectorDouble:
                return(ReadVectorDouble());

            case Amf3TypeCode.Dictionary:
                return(ReadDictionary());

            case Amf3TypeCode.VectorObject:
                return(ReadVectorObject());

            default:
                throw new NotImplementedException("Cannot parse type " + type.ToString());
            }
        }
Exemplo n.º 6
0
 private void Write(Amf3TypeCode type)
 {
     Stream.WriteByte((byte)type);
 }