Skip to content

Add support for searching registrations in assemblies #10

@ArnaudB88

Description

@ArnaudB88

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)?

  1. 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());
        }
    }
  1. 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

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions