Registering Multiple Implementation With Same Interface
We have an interface with name IVehicle public interface IVehicle { string Type { get ; set ; } } We have 3 Implementations of this interface Car , Van and Truck . public class Car : IVehicle { public string Type { get ; set ; } = "Car" ; } public class Truck : IVehicle { public string Type { get ; set ; } = "Truck" ; } public class Van : IVehicle { public string Type { get ; set ; } = "Van" ; } We have a CarController , where we want to use the Car implementation of IVehicle . [ Route( "/api/cars" ) ] [ ApiController ] public class CarController : ControllerBase { private IVehicle _vehicle; public CarController ( IVehicle vehicle ) { _vehicle = vehicle; } } It is a usual approach to inject any service. But, in our case IVehcle have 3 implementations.However, determining which implementation is in use is not straightforward with our current method. To addr...