Created
April 5, 2024 07:25
-
-
Save usausa/549ac12003ca61032268bb36d864dba1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.DependencyInjection; | |
public sealed class KeyedServiceProxy<T> | |
where T : notnull | |
{ | |
private readonly IServiceProvider serviceProvider; | |
public KeyedServiceProxy(IServiceProvider serviceProvider) | |
{ | |
this.serviceProvider = serviceProvider; | |
} | |
public T Get(object key) => serviceProvider.GetRequiredKeyedService<T>(key); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment