public byte[] Encode(BaseProtocolVO vo) { var binWriter = new ProtocolBinaryWriter(new MemoryStream()); binWriter.Write(vo.MessageId); vo.encode(binWriter); binWriter.Seek(0, SeekOrigin.Begin); int len = (int)binWriter.BaseStream.Length; var bytes = new byte[len]; binWriter.BaseStream.Read(bytes, 0, len); return bytes; }
//子类覆写 public virtual void encode(ProtocolBinaryWriter binWriter) { }