Skip to content

Instantly share code, notes, and snippets.

@bayological
Last active September 13, 2018 15:09
Show Gist options
  • Save bayological/5edfb5d0ba6149a14fa77e520b2ffbc4 to your computer and use it in GitHub Desktop.
Save bayological/5edfb5d0ba6149a14fa77e520b2ffbc4 to your computer and use it in GitHub Desktop.
Extension method to get the specific registered type
public static IServiceCollection Named<TService, TImplementation>(this IServiceCollection services, string name)
{
var implementationToBeNamed = services.FirstOrDefault(s => s.ImplementationType == typeof(TImplementation) &&
s.ServiceType == typeof(TService));
return services;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment