Is your feature request related to a problem? Please describe.
Currently, many generic extension methods exist on the IServiceCollection to support the registration of services. One that seems to be missing is a TryAddEnumerable extension which supports generics. The remarks for TryAddEnumerable recommend it for situations where multiple implementations are being registered. Currently, when using TryAddEnumerable it's one the few cases I've found where the user must also understand how to directly create a ServiceDescriptor.
Describe the solution you'd like
Something along the lines of this would be sufficient as a minimum, although perhaps other overloads would be useful to support the different lifetimes...
public static void TryAddEnumerable<TService, TImplementation>(this IServiceCollection collection, ServiceLifetime serviceLifetime)
where TService : class
where TImplementation : class, TService
{
var serviceDescriptor =
ServiceDescriptor.Describe(typeof(TService), typeof(TImplementation), serviceLifetime);
collection.TryAddEnumerable(serviceDescriptor);
}
If this looks reasonable I'd be happy to submit a PR for this and any other extension methods that would be helpful.
Describe alternatives you've considered
N/A
Additional context
N/A
Is your feature request related to a problem? Please describe.
Currently, many generic extension methods exist on the IServiceCollection to support the registration of services. One that seems to be missing is a TryAddEnumerable extension which supports generics. The remarks for TryAddEnumerable recommend it for situations where multiple implementations are being registered. Currently, when using TryAddEnumerable it's one the few cases I've found where the user must also understand how to directly create a ServiceDescriptor.
Describe the solution you'd like
Something along the lines of this would be sufficient as a minimum, although perhaps other overloads would be useful to support the different lifetimes...
If this looks reasonable I'd be happy to submit a PR for this and any other extension methods that would be helpful.
Describe alternatives you've considered
N/A
Additional context
N/A