Resolve and ResolveAll

18 views
Skip to first unread message

StuartM

unread,
Dec 23, 2011, 9:07:42 AM12/23/11
to Castle Project Users
Newbies question peeps so please don't flame me if its not relevant!

I have added an installer class which correctly installs a set of
handlers based on ITransformer interface.

Heres the code for the installer:

public class TransformerInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container,
IConfigurationStore store)
{
var types = AllTypes.FromThisAssembly()
.BasedOn<ITransformer>()
.Configure(r =>
r.Named(r.Implementation.Name));
container.Register(types);
}
}

I then runup a test which creates the container as follows:

_container = new WindsorContainer();
_container.Install(new TransformerInstaller());

I then try to find my 1 interface in the following ways:

var resolved =
_container.Resolve<ITransformer>("TransFormerClassName");
var resolvedStuff = _container.ResolveAll<ITransformer>();
var resolvedNamedStuff =
_container.ResolveAll<ITransformer>("TransFormerClassName");

resolved correctly points to the transformer
resolvedStuff and resolvedNamedStuff are both zero length arrays.

Surely ResolveAll should resolve all interfaces of this type? Or am I
missing something.

This is using 3.0 on an Windows7 platform under .Net4

Krzysztof Koźmic

unread,
Dec 23, 2011, 7:20:32 PM12/23/11
to castle-pro...@googlegroups.com
Everything works as designed.

You're not registering those types as ITransformer, hence you can't
resolve them as ITransformer

K

Jason Meckley

unread,
Dec 24, 2011, 6:40:43 AM12/24/11
to castle-pro...@googlegroups.com
to expand on Krysztof's response. add 
   .WithService.Base()
to your registration.

Stuart Murray

unread,
Dec 30, 2011, 7:21:09 AM12/30/11
to castle-pro...@googlegroups.com

Thanks for the replies guys.  That seems to work.

However I must admit to still being confused as the Resolve() method worked in the original case.

 

I’ll continue reading around to see if I can knock some knowledge into my brain!

 

Thanks again

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/VECClN2MzZkJ.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.

Reply all
Reply to author
Forward
0 new messages