3 ms·
Absolutely nothing in that blog post applied to what I intended, because I did not say that a generic method that looks up implementations in a registry should
by DougWebb 6y ago
Absolutely nothing in that blog post applied to what I intended, because I did not say that a generic method that looks up implementations in a registry should be used. My static method would be explicitly coded to return a particular implementation, and there would be a separate static method for each kind of service you need. (Eg: one per interface if you're using interfaces for the return types.)
No registration or configuration is needed, because the types are hard coded. If you need mocking support, a single IsTest config setting could be used in a conditional statement to determine which implementation to return.
That's very little additional coding if you use a ternary statement, and it lets you opt-in to the mocking mechanism if/when/where you need it, instead of permiating your entire architecture with it.