Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Difference between ResolveAll and Enumerable.

Eugene Sadovoi edited this page Dec 17, 2018 · 5 revisions

ResolveAll

Historically Unity did not natively support resolving enumerable. It supported resolving arrays of dependencies but only if these where registered with name. Consider this example:

RegisterType(typeof(IService), typeof(Service));
RegisterType(typeof(IService), typeof(Service),  "Name-1");
RegisterType(typeof(IService), typeof(Service1), "Name-2");
RegisterType(typeof(IService), typeof(Service1), "Name-3");
RegisterType(typeof(IService), typeof(Service1), "Name-4");

When calling ResolveAll<IService> (Resolve<IService[]>) Unity would only return 4 items. These with 'Name-x'.

IEnumerable

Above behavior does not work in all the cases so support for IEnumerable<> has been added. As opposed to ResolveAll resolving Resolve<IEnumerable<SomeType>>() will return all registrations satisfying IServece. So in example above it will return all 5 objects.

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.