New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Batch-Registration overloads for Register with single or params Assembly #486

dotnetjunkie opened this Issue Nov 13, 2017 · 1 comment


1 participant

dotnetjunkie commented Nov 13, 2017

The batch-registration overloads for Register currently only support passing an IEnumerable<Assembly>, while a common use case is to pass a single assembly, or a fixed set of assemblies. This has to be wrapped in an array. Example:

container.Register(typeof(IValidator<>), new[]{ typeof(IValidator<>).Assembly,typeof(X).Assembly});

container.Register(typeof(IValidator<>), new[] { typeof(ICommand).Assembly }, Lifestyle.Scoped);

The following two overloads make these common use cases easier:

Register(Type openGenericServiceType, params[] Assembly assemblies)
Register(Type openGenericServiceType, Assembly assembly, Lifestyle lifestyle)

This would result in the following user code:

container.Register(typeof(IValidator<>), typeof(IValidator<>).Assembly, typeof(X).Assembly);

container.Register(typeof(IValidator<>), typeof(ICommand).Assembly, Lifestyle.Scoped);

Since it is the convention to have the Lifestyle parameter last in any API call, it is not possible to have that overload use a params argument. In case a user needs to supply a fixed set of multiple assemblies, while providing a Lifestyle, the existing overload needs to be used, which means the user will still has to wrap the assemblies in an array.

AFAIK These overloads can be added without causing breaking changes.


This comment has been minimized.


dotnetjunkie commented Feb 26, 2018

Fixed with 8ebe0f9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment