private void WriteObject(List <byte> ret, TypedObject val) { if (val.type == null || val.type.Equals("")) { ret.Add((byte)0x0B); // Dynamic class ret.Add((byte)0x01); // No class name foreach (string key in val.Keys) { WriteString(ret, key); Encode(ret, val[key]); } ret.Add((byte)0x01); // End of dynamic } else if (val.type.Equals("flex.messaging.io.ArrayCollection")) { ret.Add((byte)0x07); // Externalizable WriteString(ret, val.type); Encode(ret, val["array"]); } else if (val.type.Equals("DSK")) { WriteInt(ret, (val.Count << 4) | 3); // Inline + member count WriteString(ret, val.type); byte[] flag1 = new byte[8]; byte[] flag2 = new byte[8]; if (val["body"] != null) { flag1[0] = 1; } if (val["clientId"] != null) { flag1[1] = 1; } if (val["destination"] != null) { flag1[2] = 1; } if (val["headers"] != null) { flag1[3] = 1; } if (val["messageId"] != null && val["clientId"] != null) { flag1[4] = 1; } if (val["timestamp"] != null && val["destination"] != null) { flag1[5] = 1; } if (val["timeToLive"] != null && val["headers"] != null) { flag1[6] = 1; } if (val["clientIdBytes"] != null) { flag2[0] = 1; } if (val["messageIdBytes"] != null) { flag2[1] = 1; } WriteObject(ret, val.GetTO("data")); } else { WriteInt(ret, (val.Count << 4) | 3); // Inline + member count WriteString(ret, val.type); List <String> keyOrder = new List <String>(); foreach (string key in val.Keys) { WriteString(ret, key); keyOrder.Add(key); } foreach (string key in keyOrder) { Encode(ret, val[key]); } } }