Keyed Services
Several implementations of one service, chosen by key.
What is Keyed Services?
Keyed services register several implementations of one interface under different keys, and inject the one you want with [FromKeyedServices].
builder.Services.AddKeyedSingleton<IMessageSender, EmailSender>("email");
builder.Services.AddKeyedSingleton<IMessageSender, SmsSender>("sms");
public class Alerts([FromKeyedServices("sms")] IMessageSender sender) { }
Level: Freelancer · More ASP.NET Core terms at this level
Updated