Get information about DI container:
So I’ve read that it’s a bad idea to pass a DI container into a class and use .get() because it’s a service locator pattern which isn’t recommended. I’m trying to make a cli with a plugin system and as part of that I want to have a debug command that returns all the registered plugins from the di container. Is there a best practice way to do this using Autofac ? I want to have a class like ContainerService which has some methods to get registered services, find their file locations etc.
3 Replies
if all the plugins implement for example
IPlugin
, you can ask autofac to resolve IEnumerable<IPlugin>
to get them all, or you can also register them with metadata to later useOh that’s actually a lot easier than I expected haha
I’ll give that a try thank you !
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View