-
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Enhancement 🔨Improvement of existing featuresImprovement of existing featuresQuestion ❔Issue is a questionIssue is a question
Description
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:
public class FooRegistry : Registry
{
public override void Register(IUnityContainer container, Func<LifetimeManager> createLifetimeManager)
{
container.RegisterType<IBar, Bar>(createLifetimeManager());
}
}
- It is possible to specify that unity would search for these type of classes.
Example:
//separate method
container.SearchForRegistries(lifetimeManager);
//or expanding existing method
container.RegisterTypes(....., SearchForRegistries: true);
Metadata
Metadata
Assignees
Labels
Enhancement 🔨Improvement of existing featuresImprovement of existing featuresQuestion ❔Issue is a questionIssue is a question