public IPayload <TData> GetPayload <TData>(Message message) { using (var stream = new ValueStream(message.Data)) { var commandId = stream.ReadInt32(); var commandType = commandHolder.GetCommand(commandId); var genericArgument = commandHolder.GetGenericArgument(commandType); encryption.Decrypt(stream); compression.Decompress(stream); var data = serializer.Deserialize(stream, genericArgument); return(new Payload <TData> { CommandType = commandType, Data = (TData)data }); } }