DEV Community

Discussion on: .NET 6 Register Services using Reflection

Collapse
 
nglessner profile image
nglessner

This is great stuff. Exactly what I was looking for. A couple possible improvements. If you're using Attributes (recommended) you can decorate the service (interface) rather than the implementation. This then removes the need for the naming convention (IImplementation) and the magic string in your registration reflection method. Reflection can lookup any classes that have an interface decorated with your custom attribute. At that point you have everything you need for DI registration