AMF协议的数据读取代码解析(1)(4)
7.Array对应的就是.net中的ArrayList对象,该对象首先使用32位整数定义了ArralyList的长度,然后是密集的跟着ArrayList中的对象,读取该对象使用如下函数:
- private ArrayList ReadArray()
- { int size = ReadInt32();
- ArrayList arr = new ArrayList(size);
- for (int i = 0; i < size; ++i)
- {arr.Add(ReadData(ReadByte())); }
- return arr;}
8.Date对应.net中的DateTime数据类型,Date在类型标识符0x0B后使用double来表示从1970/1/1到表示的时间所经过的毫秒数,然后再跟一个ushort的16位无符号整数表示时区。读取Date类型的C#代码为:
- private DateTime ReadDate()
- {double ms = ReadDouble();
- DateTime BaseDate = new DateTime(1970, 1, 1);
- DateTime date = BaseDate.AddMilliseconds(ms);
- ReadUInt16(); //get's the timezone
- return date; }
9.LongString对应的也是string类型,不过和2对应的String不同的是这里使用32位整数来表示字符串的UTF8长度,而String使用的是16位。
10.XML是使用类型标识符0x0F后直接跟LongString类型的字符串表示。
评论暂时关闭