After using other DI containers like Microsoft Unity, StructureMap and Autofac, I'm now using the built-in Microsoft.Extensions.DependencyInjection DI container most of the time. The default DI container lacks some more advanced features that these other containers have, but for most use cases it is sufficient.
Most of the time when registering a type as a service, you want to register it with the interface it implements:
To simplify this I created an extension method AsImplementedInterfaces that register a type with all its interfaces:
To use this method, you call any of the Add methods on the IServiceProvider and call the AsImplementedInterfaces method afterwards:
Feel free to use it in your own projects...
Remark: If you are looking for some other convenience methods that can help you when using the default DI container, check out Scrutor.