I don't think so.

OOTB Windsor will just take the first component for given service.
You could make this work by using TypedFactoryFacility relying on either naming convention

public interface IFactory
{
   public A GetA1(int x);//would return a1
   public A GetA2(string x); //would return a2
}

or custom ITypedFactoryComponentSelector that would route to the appropriate component based on parameters you pass.
http://using.castleproject.org/display/IoC/Typed+Factory+Facility


This has also the architectural advantage of not using container as service locator which I loathe ;)

cheers,
Krzysztof



On 2010-03-24 11:51, Maciej Paszta wrote:
Hi,
I encountered following problem:
I have:
 1) interface IA
 2) class A : IA
 3) class A1 : A with prop int X and ctor(int x)
 4) class A2 : A with prop string X and ctor(string x)

I register them in container in following way:

cont.AddComponentLifeStyle<IA, A1>(LifestyleType.Transient);
cont.AddComponentLifeStyle<IA, A2>(LifestyleType.Transient);
cont.AddComponentLifeStyle<A, A1>("a1", LifestyleType.Transient);
cont.AddComponentLifeStyle<A, A2>("a2", LifestyleType.Transient);

Now i want to resolve A, basing on type which I supply to ctor, so I want the following code to work:

A a1 = cont.Resolve<A> (new {x = 1});
A a2 = cont.Resolve<A>(new { x = "xxx" });

However I get ConverException.
Is there a way to get this functionality to work in Windsor?


--
You received this message because you are subscribed to the Google Groups "Castle 
Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to