Exemplo n.º 1
0
        public static object ReadAmf(Stream stm, CRefTable rt)
        {
            int type = stm.ReadByte();

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

            case DataType.Null:
                return(null);

            case DataType.False:
                //Console.WriteLine(false);
                return(false);

            case DataType.True:
                //Console.WriteLine(true);
                return(true);

            case DataType.Integer:
                uint aaa = ReadInt(stm);
                //Console.WriteLine(aaa);
                return(aaa);

            case DataType.Double:
                double aaa1 = CDataHelper.BE_ReadDouble(stm);
                //Console.WriteLine(aaa1);
                return(aaa1);

            case DataType.String:

                string sss = ReadString(stm, rt);
                //Console.WriteLine(sss);
                return(sss);

            case DataType.XmlDoc:
                break;

            case DataType.Date:
                break;

            case DataType.Array:
                return(ReadArray(stm, rt));

            case DataType.Object:
                return(ReadHashObject(stm, rt));

            case DataType.Xml:
                break;

            case DataType.ByteArray:
                return(CAmf3Helper.GetObject(ReadByteArray(stm, rt)));

            default:
                break;
            }
            //throw new Exception("暂未处理的数据类型"+type);
            return(null);
        }
Exemplo n.º 2
0
        protected static object ReadAmf(Stream stm, ref bool objEnd)
        {
            int  type = stm.ReadByte();
            bool oe   = true;

            switch ((DataType)type)
            {
            case DataType.Number:
                return(CDataHelper.BE_ReadDouble(stm));

            case DataType.Boolean:
                return(stm.ReadByte() != 0x0);

            case DataType.String:
                return(CDataHelper.BE_ReadShortStr(stm));

            case DataType.Object:
                return(ReadHashObject(stm));

            case DataType.MovieClip:
                break;

            case DataType.Null:
                return(null);

            case DataType.Undefined:
                return(null);

            case DataType.Reference:
                break;

            case DataType.MixedArray:
                CDataHelper.BE_ReadUInt32(stm);     // highest numeric index
                return(ReadHashObject(stm));

            case DataType.EndOfObject:
                Trace.Assert(!objEnd, "此处不应出现EndOfObject");
                objEnd = true;
                return(null);

            case DataType.Array:
            {
                uint     len = CDataHelper.BE_ReadUInt32(stm);
                object[] ary = new object[len];
                for (uint i = 0; i < len; i++)
                {
                    ary[i] = ReadAmf(stm, ref oe);
                }
                return(ary);
            }

            case DataType.Date:
                break;

            case DataType.LongString:
                return(CDataHelper.BE_ReadLongStr(stm));

            case DataType.Unsupported:
                return(null);

            case DataType.Recordset:
                break;

            case DataType.XML:
                break;

            case DataType.TypedObject:
                break;

            case DataType.AMF3data:
                return(CAmf3Helper.Read(stm));

            default:
                break;
            }

            Trace.Assert(false, "暂未处理的数据类型");
            return(null);
        }