public Message GetMessage <TData>(IPayload <TData> payload) { using (var stream = new ValueStream(arrayPool)) { var commandId = commandHolder.GetCommand(payload.CommandType); stream.WriteInt32(commandId); serializer.Serialize(stream, payload.Data); compression.Compress(stream); encryption.Encrypt(stream); return(new Message(stream.Buffer, (int)stream.Length)); } }