Open ArnaudB88 opened 5 years ago
I been thinking about adopting Microsoft's convention from either MEF, MEF2 or both. It has all the necessary classes and attributes already built into the framework and should be easily adopted. I am trying to avoid inventing new ways of doing well known things.
Perhaps I could add an attribute to find and execute a static method on static class to do something like you propose. I need more info on that.
I don't have any experience with MEF, but I agree that this functionality should not be 'a new invention'. I got my thoughts from the (deprecated) library StructureMap which we also use on some projects. A possible implementation for this functionality can also be found there.
Support for searching 'registration classes' would be helpful when configuring registrations in a big solution. Registration-by-convention is a big help for general registrations, but custom ones should be written separately. In our solution, we have written such custom registrations in each project in a separate class. To avoid calling those classes manually, auto-search for these 'registration classes' would be helpful. This functionality can be found in StructureMap: http://structuremap.github.io/registration/auto-registration-and-conventions/ (See 'Scan for Registries')
How should it look like for us (the users)?
We can create classes which inherit from a unity class (eg. Registry) with one method (or constructor). Within that method, container registrations can be written. This can be useful if registrations-by-convention should be overwritten with a custom registration (for eg. decorators/interceptors) Example:
It is possible to specify that unity would search for these type of classes. Example: