Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats ResolveAll do

In IOC's what does ResolveAll do?? I know that the offical answer is "Resolve all valid components that match this type." Does that mean that it will return any class that implements a given interface?

like image 204
vdhant Avatar asked Dec 05 '08 07:12

vdhant


3 Answers

It will return all classes that were registered for a given interface.

...and are not waiting on any references to be resolved. This bit me today!

like image 152
Chris Bilson Avatar answered Oct 11 '22 07:10

Chris Bilson


With Unity, ResolveAll resolves each registered mapping for an interface except for the default mapping.

so if you registered:

container.RegisterType<IInterface, ActualClassOne>(new ContainerControlledLifetimeManager());
container.RegisterType<IInterface, ActualClassOne>("Singleton", new ContainerControlledLifetimeManager());
container.RegisterType<IInterface, ActualClassOne>("Trans", new TransientLifetimeManager());

ResolveAll() will only give you an IEnumerable containing a resolved "Singleton" and "Trans" mappings

like image 21
LukeN Avatar answered Oct 11 '22 06:10

LukeN


It will return all classes that were registered for a given interface.

like image 22
Andrey Shchekin Avatar answered Oct 11 '22 06:10

Andrey Shchekin