Hi!
I have a question to ask about Service Locator.
I have a piece of code listening to messages coming from the queue, gets the message type T and uses an IServiceProvider to create a scope and dynamically resolve a IMessageHandler<T> and invoke it. Is such usage considered a Service Locator? I would argue that my code is more a piece of infrastructure, similar to what MVC does to instantiate a controller for each request.

If it's still a wrong way to use it, how would you suggest to refactor this? The only thing coming to mind is that I could accept a dictionary of <Type, Func<IMessageHandler<T>>> through constructor injection and that dictionary would be configurable in Composition Root.
Bu that seems an overkill...

Thanks for any suggestions!