public void WriteAmf0Object(Amf0Object obj) { bw.WriteMapleString(obj.name); if (obj.data == null) { bw.WriteByte(5); } else if (obj.data is List <Amf0Object> ) { if (obj.type == Amf0Object.Amf0Type.AMF0_ECMA_ARRAY) { bw.WriteByte((byte)obj.type); var list = obj.data as List <Amf0Object>; bw.WriteInt(list.Count); int counter = 0; foreach (var lobj in list) { if (lobj.name == null) { lobj.name = counter++.ToString(Program.Culture); } WriteAmf0Object(lobj); } bw.WriteShort(0); bw.WriteByte(9); } else //OBJECT { obj.type = Amf0Object.Amf0Type.AMF0_OBJECT; bw.WriteByte((byte)obj.type); var list = obj.data as List <Amf0Object>; int counter = 0; foreach (var lobj in list) { if (lobj.name == null) { lobj.name = counter++.ToString(Program.Culture); } WriteAmf0Object(lobj); } bw.WriteShort(0); bw.WriteByte(9); } } else if (obj.data is int || obj.data is double || obj.data is float) { if (!(obj.data is double)) { var data = Convert.ToDouble(obj.data); obj.data = data; } obj.type = Amf0Object.Amf0Type.AMF0_NUMBER; bw.WriteByte((byte)obj.type); bw.WriteDouble((double)obj.data); } else if (obj.data is string) { obj.type = Amf0Object.Amf0Type.AMF0_STRING; bw.WriteByte((byte)obj.type); bw.WriteMapleString((string)obj.data); } else if (obj.data is bool) { bw.WriteByte((byte)Amf0Object.Amf0Type.AMF0_BOOLEAN); bw.WriteByte(Convert.ToByte(obj.data)); } else { throw new Exception("Unable to write type to sol file"); } }