Ejemplo n.º 1
0
        AmfObject ReadVector(AmfTypes type)
        {
            // Stored by ref?
            bool isInstance;
            int  lengthOrIndex = ReadU29(out isInstance);

            if (!isInstance)
            {
                return((AmfObject)_objectLookup[lengthOrIndex]);
            }

            // Stored by value
            var result = new AmfObject(type);

            _objectLookup.Add(result);

            result.IsFixedVector = _reader.ReadBoolean();
            if (type == AmfTypes.VectorGeneric)
            {
                result.GenericElementType = ReadString();
            }

            for (int j = 0; j < lengthOrIndex; ++j)
            {
                switch (type)
                {
                case AmfTypes.VectorInt:
                    result.Push(ReadI32());
                    break;

                case AmfTypes.VectorUInt:
                    result.Push(ReadU32());
                    break;

                case AmfTypes.VectorDouble:
                    result.Push(ReadDouble());
                    break;

                case AmfTypes.VectorGeneric:
                    result.Push(ReadValue());
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        AmfObject ReadArray()
        {
            // Stored by ref?
            bool isInstance;
            var  indexOrCount = ReadU29(out isInstance);

            if (!isInstance)
            {
                return((AmfObject)_objectLookup[indexOrCount]);
            }

            // Stored by value
            var result = new AmfObject(AmfTypes.Array);

            _objectLookup.Add(result);

            // Associative part (key-value pairs)
            while (true)
            {
                var key = ReadString();
                if (key == "")
                {
                    break;
                }

                var value = ReadValue();
                result[key] = value;
            }

            // Dense part (consecutive indices >=0 and <count)
            for (int i = 0; i < indexOrCount; i++)
            {
                var value = ReadValue();
                result.Push(value);
            }

            return(result);
        }