Re: Constructor injection by name

2018-09-10 Thread 'Jordan' via Castle Project Users
Ah no! I didn't try that.
Thankyou, that could be ok. 

I'd just switched to using ServiceOverride.ForKey which is working but 
doesn't give me the thrill of automatic registration :)

Jordan.


On Monday, September 10, 2018 at 4:05:11 PM UTC+1, Svetoslav Milenov - 
Sunny wrote:
>
> Did you try to iniect IEnumerable? This will inject both in 
> the order of registration.
>
> Cheers,
> Sunny
>
> On Mon, Sep 10, 2018, 9:18 AM 'Jordan' via Castle Project Users <
> castle-pro...@googlegroups.com > wrote:
>
>> Hi all,
>>
>> If there are 2 different named implementations of an interface in the 
>> container, will the first one be always be automatically selected by the 
>> container for constructor injection?
>>
>> Is there any way of automatically injecting both instances into a 
>> constructor?  Or a dictionary of all implementations?
>>
>> eg if there are 2 named implementations of ISomeService, 
>> "defaultSomeService", and "alternativeSomeService",  and I have a 
>> constructor like this:
>>
>>
>> public SomeOtherComponent(ISomeService defaultSomeService, 
>> ISomeService alternativeSomeService) 
>> {
>>   //
>> }
>>
>> is there any way of getting the container to automatically inject both 
>> implementations by name? Or will "defaultSomeService" just be injected 
>> twice ?
>>
>> thanks,
>> Jordan
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Castle Project Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to castle-project-users+unsubscr...@googlegroups.com .
>> To post to this group, send email to castle-pro...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/castle-project-users.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to castle-project-users+unsubscr...@googlegroups.com.
To post to this group, send email to castle-project-users@googlegroups.com.
Visit this group at https://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.


Re: Constructor injection by name

2018-09-10 Thread Sunny
Did you try to iniect IEnumerable? This will inject both in
the order of registration.

Cheers,
Sunny

On Mon, Sep 10, 2018, 9:18 AM 'Jordan' via Castle Project Users <
castle-project-users@googlegroups.com> wrote:

> Hi all,
>
> If there are 2 different named implementations of an interface in the
> container, will the first one be always be automatically selected by the
> container for constructor injection?
>
> Is there any way of automatically injecting both instances into a
> constructor?  Or a dictionary of all implementations?
>
> eg if there are 2 named implementations of ISomeService,
> "defaultSomeService", and "alternativeSomeService",  and I have a
> constructor like this:
>
>
> public SomeOtherComponent(ISomeService defaultSomeService,
> ISomeService alternativeSomeService)
> {
>   //
> }
>
> is there any way of getting the container to automatically inject both
> implementations by name? Or will "defaultSomeService" just be injected
> twice ?
>
> thanks,
> Jordan
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to castle-project-users+unsubscr...@googlegroups.com.
> To post to this group, send email to castle-project-users@googlegroups.com
> .
> Visit this group at https://groups.google.com/group/castle-project-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to castle-project-users+unsubscr...@googlegroups.com.
To post to this group, send email to castle-project-users@googlegroups.com.
Visit this group at https://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.


Constructor injection by name

2018-09-10 Thread 'Jordan' via Castle Project Users
Hi all,

If there are 2 different named implementations of an interface in the 
container, will the first one be always be automatically selected by the 
container for constructor injection?

Is there any way of automatically injecting both instances into a 
constructor?  Or a dictionary of all implementations?

eg if there are 2 named implementations of ISomeService, 
"defaultSomeService", and "alternativeSomeService",  and I have a 
constructor like this:


public SomeOtherComponent(ISomeService defaultSomeService, 
ISomeService alternativeSomeService) 
{
  //
}

is there any way of getting the container to automatically inject both 
implementations by name? Or will "defaultSomeService" just be injected 
twice ?

thanks,
Jordan


-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to castle-project-users+unsubscr...@googlegroups.com.
To post to this group, send email to castle-project-users@googlegroups.com.
Visit this group at https://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.