Dynamic MediatR response

14 views Asked by At

Let's say I have these classes:

class StuffResponse { ... }
class StuffButLongerResponse : Response { ... }
class StuffCommand : IRequest<???>
class EverythingRelatedToStuffCommandHandler : IRequestHandler<StuffResponse<???>, <???>>

Also, I have a bunch of Web API endpoints which receive more or less the same input, with some differences. I will map the request object from these endpoints into a single command. Based on conditions on this command, the command handler should sometimes return a single Stuff() object, sometimes it should return a single StuffButLonger() object, sometimes a list of either of these two types.

Something like this:

enter image description here

Is something like this possible?

0

There are 0 answers