Closed Naxaliav closed 3 years ago
I don't ensure anything, this is a feature of the container you decide to use. In fact, all container registration/resolution functionality is 100% delegated to the container. This library doesn't rely on anything or make any assumptions.
Thank you @jbogard :)
Hello 👋 I was looking into source code of MediatR and MediatR.Extensions.Microsoft.DependencyInjection and I could not find the place where you ensure that pipelineBehaviors are executed in the right order.
On command execution, all related IPipelineBehaviors are executed through pipeline. ref
Example code: (with 1x preprocessor, 2x postprocessor which just prints to console and are not visible in code snippet)
Produces output:
Looking into example above, the sequence how PipelineBehaviors are executed is somehow 0,4,5,1,2,3. I tried changing the order of registration, but it worked good at all times. I tried to look into source code, I could not find a place where you ensure that pre processor behavior is executed before any other additionally registered behavior. Same goes to post processor, it is always executed after all pipeline behaviors, it does not matter whether they are built in or custom.
Where is the magic? 😁
I have looked into test classes and found
" / It appears Autofac returns the last registered types first"
, so do you somehow rely on how it is registered to DI? ref