Пример #1
0
        public byte[] ToBuffer()
        {
            byte[] data = BufferHelper.Serialize(_data);
            byte[] id   = BitConverter.GetBytes(MessageID);

            byte[] buffer = new byte[data.Length + id.Length];
            Buffer.BlockCopy(id, 0, buffer, 0, id.Length);
            Buffer.BlockCopy(data, 0, buffer, id.Length, data.Length);
            return(buffer);
        }
Пример #2
0
 public void FromBuffer(byte[] buffer)
 {
     _messageID = BitConverter.ToInt32(buffer, 0);
     _data      = BufferHelper.Deserialize(buffer, 4);
 }