Skip to content

Instantly share code, notes, and snippets.

Created Sep 29, 2018
What would you like to do?
public static class ServiceCollectionExtensions
public static void AddFactory<TService, TImplementation>(this IServiceCollection services)
where TService : class
where TImplementation : class, TService
services.AddTransient<TService, TImplementation>();
services.AddSingleton<Func<TService>>(x => () => x.GetService<TService>());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment