public static void AddScoped <TInterface, TService>([NotNull] this IKeyedServiceRegistrar registrar, object key) where TInterface : class where TService : class, TInterface { registrar.Services.AddScoped <TService>(); registrar.Services.AddScoped <TInterface, TService>(); registrar.Add <TInterface, TService>(key); }
public static void AddTransient <TInterface, TService>([NotNull] this IKeyedServiceRegistrar registrar, object key, Func <IServiceProvider, TService> implementationFactory) where TInterface : class where TService : class, TInterface { registrar.Services.AddTransient(implementationFactory); registrar.Services.AddTransient <TInterface, TService>(s => s.GetService <TService>()); registrar.Add <TInterface, TService>(key); }
public static void Add <TInterface, TService>([NotNull] this IKeyedServiceRegistrar registrar, object key) where TService : class, TInterface { registrar.Add(typeof(TInterface), typeof(TService), key); }