I have a API that is responsible for processing some documents that are posted to it. To do this I have a controller with endpoints for different file types such as "word", "excel", "image" etc.
This controller is injected with a service responsible for handling the processing.
private readonly IDocProcessor documentProcessor;
public MyController(IDocProcessor docProcessor)
{
documentProcessor = docProcessor;
}
This is all working perfectly, I now have the requirement to modify the processing, in just the "image" endpoint, due to a limitation in a third-party component.
So, what I want to do is write another service which implements IDocProcessor for images. It will not be used for the others, so will simply throw a NotImplementedException.
What I am struggling with is how I can inject both services into the controller? Or the best practice for doing this.
I have been reading through this question How to register multiple implementations of the same interface in Asp.Net Core? for some pointers, but some of the answers are few years old so wonder if there are new ways to achieve this?