private static PmlElement ReadData(BinaryReader Reader, AmfDataType EType) { switch (EType) { case AmfDataType.Number: Double d = ReadDouble(Reader); if (d == (double)(Int64)d) { return(new PmlInteger((Int64)d)); } else if (d == (double)(UInt64)d) { return(new PmlInteger((UInt64)d)); } else { return(new PmlString(d.ToString())); } case AmfDataType.Boolean: return(new PmlInteger(Reader.ReadByte())); case AmfDataType.String: return(new PmlString(ReadShortString(Reader))); case AmfDataType.Array: PmlCollection ElementC = new PmlCollection(); int size = ReadInt32(Reader); for (int i = 0; i < size; ++i) { ElementC.Add(ReadElementFrom(Reader)); } return(ElementC); case AmfDataType.Date: return(new PmlString(ReadDate(Reader).ToString())); case AmfDataType.LongString: return(new PmlString(ReadLongString(Reader))); case AmfDataType.TypedObject: ReadShortString(Reader); return(ReadUntypedObject(Reader)); case AmfDataType.MixedArray: return(ReadDictionary(Reader)); case AmfDataType.Null: case AmfDataType.Undefined: case AmfDataType.End: return(new PmlNull()); case AmfDataType.UntypedObject: return(ReadUntypedObject(Reader)); case AmfDataType.Xml: return(new PmlString(ReadLongString(Reader))); case AmfDataType.MovieClip: case AmfDataType.ReferencedObject: case AmfDataType.TypeAsObject: case AmfDataType.Recordset: default: throw new NotSupportedException("The AMF type is not supported: " + EType.ToString()); } }
private static PmlElement ReadElementFrom(BinaryReader Reader) { AmfDataType EType = (AmfDataType)Reader.ReadByte(); return(ReadData(Reader, EType)); }