How do you deal with multiple implementations of the interface prior to Keyed Services?
How do you deal with multiple implementations of the interface prior to Keyed Services?
That's a great breakdown of DI patterns. When dealing with audio processing pipelines, I've found the factory pattern especially useful for managing different audio format implementations. If you're into audio tech, check out this AI music detection tool - https://songprint.space
Before keyed services were introduced in .NET, developers typically handled multiple implementations of the same interface by injecting IEnumerable<T> and selecting the correct implementation at runtime, often using custom logic Geometry Dash Lite or a CanHandle method. Another common approach was to create a factory that encapsulated the selection logic, usually backed by the injected collection of implementations. Some teams used a dictionary-based lookup to map string keys to specific implementations for faster and more predictable access, while others relied on variations of the strategy pattern where the correct implementation was chosen at design time rather than runtime. In some cases, a service locator was used, though it is generally discouraged because it hides dependencies and makes testing harder. Overall, these approaches worked but often introduced extra boilerplate and manual management, which keyed services later simplified by providing a built-in, standardized way to register and resolve multiple implementations by key.