public OctetsStream Marshal(OctetsStream os) { MessageResponse.Marshal(os); os.Marshal(LoginStage); os.Marshal(Sex); os.Marshal(Name); os.Compact_uint32(Param.Count); foreach (KeyValuePair <string, int> e in Param) { os.Marshal(e.Key); os.Marshal(e.Value); } os.Compact_uint32(EntitySet.Count); foreach (MessageEntity v in EntitySet) { os.Marshal(v); } os.Compact_uint32(EntityList.Count); foreach (MessageEntity v in EntityList) { os.Marshal(v); } os.Compact_uint32(EntityArray.Length); foreach (MessageEntity v in EntityArray) { os.Marshal(v); } return(os); }
public void MarshalTest() { var marshall = new OctetsStream(); Assert.AreEqual(0, marshall.Size); marshall.Marshal((byte)3); Assert.AreEqual(1, marshall.Size); marshall.Marshal(true); Assert.AreEqual(2, marshall.Size); marshall.Marshal((short)32); Assert.AreEqual(4, marshall.Size); marshall.Marshal('Z'); Assert.AreEqual(6, marshall.Size); marshall.Marshal((int)328); Assert.AreEqual(10, marshall.Size); marshall.Marshal((long)328392); Assert.AreEqual(18, marshall.Size); marshall.Marshal(3.14159f); Assert.AreEqual(22, marshall.Size); marshall.Marshal(38293.3234); Assert.AreEqual(30, marshall.Size); marshall.Compact_uint32(32); Assert.AreEqual(31, marshall.Size); marshall.Compact_uint32(100); Assert.AreEqual(33, marshall.Size); marshall.Compact_sint32(-100); Assert.AreEqual(35, marshall.Size); }