Hi Krzysztof
I already try with IHandlerSelector and it works fine for the first
level resolution.
I have this configuration:

Kernel.Register(Component.For<IService>()
.Named("service1")
.UsingFactoryMethod(() => ServiceFactory.CreateService1());

Kernel.Register(Component.For<IService>()
.Named("service2")
.UsingFactoryMethod(() => ServiceFactory.CreateService2());

Kernel
  .Register(Component.For<ClassA>().ImplementedBy<ClassA>());

Where ClassA depends on IService.

I would like to resolve ClassA sometimes with Service1 and sometimes
with Service2, something like:

kernel.Resolve<ClassA>("with Service1"); // don't know the sintax!
kernel.Resolve<ClassA>("with Service2");


thx!!

ema
http://blog.codiceplastico.com



2010/5/14 Krzysztof Koźmic <[email protected]>:
> use IHandlerSelector or TypedFactoryFacility
>
> On 2010-05-14 17:18, Emanuele DelBono wrote:
>>
>> Hi again
>> I have a question about Windsor.
>>
>> I have ClassA that depends on IService and I have 2 implementations of
>> IService (Service1 and Service2):
>>
>> public class ClassA : IClassA
>> {
>>   public ClassA(IService service)
>>   {...}
>> }
>> public Service1 : IService
>> public Service2 : IService
>>
>> The implementations is provided by a factory method.
>> I registered all the components: ClassA, Service1 and Service2.
>>
>> I would like to resolve ClassA with Service1 or Service2 depending on
>> the context of the application, sometimes ClassA needs Service1 and
>> other times needs Service2.
>>
>> Do you have any hints?
>> Thanks!
>> ema
>> http://blog.codiceplastico.com
>>
>>
>
> --
> 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.
>
>

-- 
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