Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created March 4, 2024 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/56ad78438937a37d84f668769ff58f00 to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/56ad78438937a37d84f668769ff58f00 to your computer and use it in GitHub Desktop.
.NET 8 - Keyed Services Registration Demo
public static class DependencyRegistrationBootstrapper
{
public static void RegisterDependencies(this IServiceCollection services)
{
// Register three implementations
services.AddKeyedTransient<IReminderService, SmsReminderService>(ReminderType.Sms);
services.AddKeyedTransient<IReminderService, EmailReminderService>("Email");
services.AddKeyedTransient<IReminderService, PushNotificationReminderService>(ReminderType.PushNotifications);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment