-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add GetKeyedOrDefault extension to IServiceProvider #122098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Tagging subscribers to this area: @dotnet/area-extensions-dependencyinjection |
|
Thank you for your interest of contribution. Adding new API like methods require going through API review process. This method doesn't follow the contract of |
@dotnet-policy-service agree company="Microsoft" |
This PR adds the
GetKeyedOrDefault<T>extension method toIServiceProvider.This method attempts to retrieve a keyed service and falls back to
GetRequiredService<T>if the keyed service is not found.This is useful for scenarios where a default implementation should be used if a specific keyed implementation is not available.
Changes:
GetKeyedOrDefault<T>toServiceProviderKeyedServiceExtensions.csKeyedDependencyInjectionSpecificationTests.cs