Hi,
I have a project with multiple commands and queries. I need to intercept some specific commands using the Mediator pipeline.
I only see examples with generics, intercepting all the commands. Is there a way to capture only specific commands?
Using Net core 3.1, default DI
Thank you in advance
There are a few closed issues that discuss this already that you could search for. What you want is a constrained generic handler. The default dotnet core DI doesn鈥檛 support these. You鈥檒l have to switch to a 3rd party DI like Lamar, or you could probably do simple pattern matching in the behavior.
if (request is SomeRequestType)
{
...
}
There are a few closed issues that discuss this already that you could search for. What you want is a constrained generic handler. The default dotnet core DI doesn鈥檛 support these. You鈥檒l have to switch to a 3rd party DI like Lamar, or you could probably do simple pattern matching in the behavior.
if (request is SomeRequestType) { ... }
Thanks for your answer @lilasquared
I was seeking for solutions except for pattern matching. Probably I will come back to Action FIlters
Switching DI will give you what you want also. Other DIs are far more mature than the built in one.
Feel free to upvote this PR: https://github.com/dotnet/runtime/pull/39540 it would fix this.
Most helpful comment
Feel free to upvote this PR: https://github.com/dotnet/runtime/pull/39540 it would fix this.