Hey Mark,
First of all, please kindly have a look at the controllers' code again as I’ve done some tiny modifications on the Actions to conform to the REST Principles more. For example, I’ve removed “register” from the route for the POST method.
But regarding your question that how the arguments (the command object in the final design) are passed down to the handlers, it’s all in the hand of the CommandProcessor. In other words, the processor first uses typeof(ICommandHandler<TCommand>)
to get the type of the handler with the incoming command (presented as TCommand
here). Next, it tries to find the relevant command handler interface (using reflection — next line of code) and if it can find anything for that finally checking with FirstOrDefault
, then, it resolves the concrete class of that using the IComponentContext
object which is coming from Autofac
NuGet package. And eventually invoking thehandle
method from it to perform the desired operation.
Hope it helps