示例#1
0
        /// <summary>
        /// Reads an AMF body from an input stream.
        /// </summary>
        /// <param name="input">The input stream</param>
        /// <returns>The AMF body that was read</returns>
        private static AMFBody ReadAMFBody(AMFDataInput input)
        {
            string requestTarget  = input.ReadShortString();
            string responseTarget = input.ReadShortString();
            int    bodyLength     = input.ReadInt();

            IASValue content = ReadAMFContent(input, bodyLength);

            return(new AMFBody(requestTarget, responseTarget, content));
        }
示例#2
0
        private IASValue ReadMixedArray()
        {
            int length = input.ReadInt();

            if (length < 0)
            {
                throw new AMFException(ExceptionPrefix + "Encountered negative MixedArray length.");
            }

            // Important: Add the array to the cache before deserializing its properties!
            ASArray result = ASArray.CreateUninitializedInstance();

            AddObjectToCache(result);

            IASValue[] indexedValues = length == 0 ? EmptyArray <IASValue> .Instance : new IASValue[length];
            IDictionary <string, IASValue> mixedValues = null;

            for (;;)
            {
                string key = input.ReadShortString();
                if (key.Length == 0)
                {
                    break;
                }

                IASValue value = input.ReadObject();

                // If the string looks like a valid index, then stuff it into the array.
                int index;
                if (int.TryParse(key, NumberStyles.None, CultureInfo.InvariantCulture, out index) && index >= 0 && index < length)
                {
                    indexedValues[index] = value;
                }
                else
                {
                    // Otherwise add it as a mixed value.
                    if (mixedValues == null)
                    {
                        mixedValues = new Dictionary <string, IASValue>();
                    }

                    mixedValues.Add(key, value);
                }
            }

            if (mixedValues == null)
            {
                mixedValues = EmptyDictionary <string, IASValue> .Instance;
            }

            ConsumeEndOfObject();

            result.SetProperties(indexedValues, mixedValues);
            return(result);
        }
示例#3
0
        /// <summary>
        /// Reads an AMF header from an input stream.
        /// </summary>
        /// <param name="input">The input stream</param>
        /// <returns>The AMF header that was read</returns>
        private static AMFHeader ReadAMFHeader(AMFDataInput input)
        {
            string name           = input.ReadShortString();
            bool   mustUnderstand = input.ReadBoolean();
            int    headerLength   = input.ReadInt();

            IASValue content = ReadAMFContent(input, headerLength);

            return(new AMFHeader(name, mustUnderstand, content));
        }
示例#4
0
        /// <summary>
        /// Reads an AMF header from an input stream.
        /// </summary>
        /// <param name="input">The input stream</param>
        /// <returns>The AMF header that was read</returns>
        private static AMFHeader ReadAMFHeader(AMFDataInput input)
        {
            string name = input.ReadShortString();
            bool mustUnderstand = input.ReadBoolean();
            int headerLength = input.ReadInt();

            IASValue content = ReadAMFContent(input, headerLength);

            return new AMFHeader(name, mustUnderstand, content);
        }
示例#5
0
        /// <summary>
        /// Reads an AMF body from an input stream.
        /// </summary>
        /// <param name="input">The input stream</param>
        /// <returns>The AMF body that was read</returns>
        private static AMFBody ReadAMFBody(AMFDataInput input)
        {
            string requestTarget = input.ReadShortString();
            string responseTarget = input.ReadShortString();
            int bodyLength = input.ReadInt();

            IASValue content = ReadAMFContent(input, bodyLength);

            return new AMFBody(requestTarget, responseTarget, content);
        }