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 Collections.Register<T>(params) overloads. #542

dotnetjunkie opened this Issue Apr 29, 2018 · 0 comments


1 participant

dotnetjunkie commented Apr 29, 2018

There are some convenient Collections.Register<T> overloads missing that simplify registering types and assemblies:

container.Collections.Register<ILogger>(typeof(FileLogger), typeof(DbLogger));
container.Collections.Register<ILogger>(typeof(FileLogger).Assembly, typeof(DbLogger).Assembly);

Both presented methods use the params keyword to prevent having to build an enumerable or array.

WARNING: This change should not be applied to the deprecated RegisterCollection, because that would be a breaking change on the source code level! The following code would stop compiling with this addition:


In v4.2, this results in a call to RegisterCollection<T>(IEnumerable<T>). In other words, it registers an empty uncontrolled collection.

To prevent this code breaking change, these overload can be added only to the Container.Collections object, as described in the work for #541.

@dotnetjunkie dotnetjunkie added this to the v4.3 milestone Apr 29, 2018

@dotnetjunkie dotnetjunkie changed the title from Add RegisterCollection<T>(params) overloads. to Add Collections.Register<T>(params) overloads. May 11, 2018

dotnetjunkie added a commit that referenced this issue May 11, 2018

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