コード例 #1
0
        /// <summary>
        /// Adds the current unmapped value to the object reference cache.
        /// </summary>
        /// <param name="objectType"></param>
        private int AddCurrentValueToCache(AMF3ObjectTypeCode objectType)
        {
            CacheItem cacheItem = new CacheItem(objectType, objectReferenceCache.Count);

            objectReferenceCache.Add(currentValue, cacheItem);

            return(cacheItem.ReferenceId);
        }
コード例 #2
0
        public IASValue ReadObject()
        {
            // Decide what to do based on the type code.
            AMF3ObjectTypeCode typeCode = (AMF3ObjectTypeCode)input.ReadByte();

            switch (typeCode)
            {
            case AMF3ObjectTypeCode.Array:
                return(ReadArray());

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

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

            case AMF3ObjectTypeCode.False:
                return(ASBoolean.False);

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

            case AMF3ObjectTypeCode.Null:
                return(null);

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

            case AMF3ObjectTypeCode.Object:
                return(ReadObjectValue());

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

            case AMF3ObjectTypeCode.True:
                return(ASBoolean.True);

            case AMF3ObjectTypeCode.Undefined:
                return(ASUndefined.Value);

            case AMF3ObjectTypeCode.Xml:
                return(ReadXml());

            default:
                throw new AMFException(String.Format(CultureInfo.CurrentCulture, "Encountered unexpected or unsupported AMF3 object type code '{0}'.", typeCode));
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets an object from the cache.
        /// </summary>
        /// <param name="objectType">The type of object expected</param>
        /// <param name="referenceId">The object reference id</param>
        /// <returns>The cached object</returns>
        private IASValue GetObjectFromCache(AMF3ObjectTypeCode objectType, int referenceId)
        {
            if (referenceId < 0 || referenceId >= objectReferenceCache.Count)
            {
                throw new AMFException(String.Format(CultureInfo.CurrentCulture,
                                                     ExceptionPrefix + "Encountered {0} token with an object reference id '{1}' that is out of bounds.", objectType, referenceId));
            }

            CacheItem cacheItem = objectReferenceCache[referenceId];

            if (cacheItem.ObjectType != objectType)
            {
                throw new AMFException(String.Format(CultureInfo.CurrentCulture,
                                                     ExceptionPrefix + "Encountered {0} token with an object reference id '{1}' that refers to an object of a different type than expected.", objectType, referenceId));
            }

            return(cacheItem.Object);
        }
コード例 #4
0
 public CacheItem(AMF3ObjectTypeCode objectType, int referenceId)
 {
     this.ObjectType  = objectType;
     this.ReferenceId = referenceId;
 }
コード例 #5
0
 public CacheItem(AMF3ObjectTypeCode objectType, IASValue obj)
 {
     this.ObjectType = objectType;
     this.Object = obj;
 }
コード例 #6
0
 /// <summary>
 /// Adds the specified object to the reference cache.
 /// </summary>
 /// <param name="objectType">The type of object to cache</param>
 /// <param name="obj">The object to cache</param>
 private void AddObjectToCache(AMF3ObjectTypeCode objectType, IASValue obj)
 {
     objectReferenceCache.Add(new CacheItem(objectType, obj));
 }
コード例 #7
0
        /// <summary>
        /// Gets an object from the cache.
        /// </summary>
        /// <param name="objectType">The type of object expected</param>
        /// <param name="referenceId">The object reference id</param>
        /// <returns>The cached object</returns>
        private IASValue GetObjectFromCache(AMF3ObjectTypeCode objectType, int referenceId)
        {
            if (referenceId < 0 || referenceId >= objectReferenceCache.Count)
                throw new AMFException(String.Format(CultureInfo.CurrentCulture,
                    ExceptionPrefix + "Encountered {0} token with an object reference id '{1}' that is out of bounds.", objectType, referenceId));

            CacheItem cacheItem = objectReferenceCache[referenceId];
            if (cacheItem.ObjectType != objectType)
                throw new AMFException(String.Format(CultureInfo.CurrentCulture,
                    ExceptionPrefix + "Encountered {0} token with an object reference id '{1}' that refers to an object of a different type than expected.", objectType, referenceId));

            return cacheItem.Object;
        }
コード例 #8
0
 public CacheItem(AMF3ObjectTypeCode objectType, int referenceId)
 {
     this.ObjectType = objectType;
     this.ReferenceId = referenceId;
 }
コード例 #9
0
        /// <summary>
        /// Adds the current unmapped value to the object reference cache.
        /// </summary>
        /// <param name="objectType"></param>
        private int AddCurrentValueToCache(AMF3ObjectTypeCode objectType)
        {
            CacheItem cacheItem = new CacheItem(objectType, objectReferenceCache.Count);
            objectReferenceCache.Add(currentValue, cacheItem);

            return cacheItem.ReferenceId;
        }
コード例 #10
0
 public CacheItem(AMF3ObjectTypeCode objectType, IASValue obj)
 {
     this.ObjectType = objectType;
     this.Object     = obj;
 }
コード例 #11
0
 /// <summary>
 /// Adds the specified object to the reference cache.
 /// </summary>
 /// <param name="objectType">The type of object to cache</param>
 /// <param name="obj">The object to cache</param>
 private void AddObjectToCache(AMF3ObjectTypeCode objectType, IASValue obj)
 {
     objectReferenceCache.Add(new CacheItem(objectType, obj));
 }