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.


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.


Re: Intercepting method calls with an IInterceptorSelector

2018-08-09 Thread 'Jordan' via Castle Project Users
ps - MethodInfo doesn't behave nicely as the key, but MethodInfo.Name does

On Thursday, August 9, 2018 at 3:01:26 PM UTC+1, Jordan wrote:
>
> Brilliant thanks! It has all fallen into place now.
>
> I can cache the attributes for every method from the ComponentModel in a 
> dictionary using the MethodInfo as the key, and then retrieve them from the 
> cache using invocation.Method when the interceptor is called.
>
> I am of course hoping that MethodInfo behaves nicely as a key in a 
> dictionary. Not tested it yet :)
>
>
>
> On Thursday, August 9, 2018 at 2:03:58 PM UTC+1, Krzysztof Koźmic wrote:
>>
>> The ComponentModel will give your interceptor the information about the 
>> component so you can pre-cache whatever information you need to extract 
>> from the attributes (componentModel.Implementation will give you the 
>> type).
>>
>> Then in the Intercept you can quickly look that data up. It's a 
>> performance optimisation. IIRC you'll get an interceptor instance per 
>> component instance, not per method, so one interceptor will apply to all 
>> methods on an instance (unless you exclude it with IInterceptorSelector).
>>
>> Hope that makes sense
>>
>>
>>

-- 
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: Intercepting method calls with an IInterceptorSelector

2018-08-09 Thread 'Jordan' via Castle Project Users
Brilliant thanks! It has all fallen into place now.

I can cache the attributes for every method from the ComponentModel in a 
dictionary using the MethodInfo as the key, and then retrieve them from the 
cache using invocation.Method when the interceptor is called.

I am of course hoping that MethodInfo behaves nicely as a key in a 
dictionary. Not tested it yet :)



On Thursday, August 9, 2018 at 2:03:58 PM UTC+1, Krzysztof Koźmic wrote:
>
> The ComponentModel will give your interceptor the information about the 
> component so you can pre-cache whatever information you need to extract 
> from the attributes (componentModel.Implementation will give you the 
> type).
>
> Then in the Intercept you can quickly look that data up. It's a 
> performance optimisation. IIRC you'll get an interceptor instance per 
> component instance, not per method, so one interceptor will apply to all 
> methods on an instance (unless you exclude it with IInterceptorSelector).
>
> Hope that makes sense
>
>
>

-- 
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: Intercepting method calls with an IInterceptorSelector

2018-08-09 Thread 'Jordan' via Castle Project Users
Great! Thanks.

So given that each transaction on a single service may be configured 
differently, does the ComponentModel passed in tell me the method that is 
being intercepted?

And If an interceptor is added to the container and marked as transient, 
will a new instance be created for each method on a component that is being 
intercepted?

thanks,
Jordan.



So in the case of does target.Configuration.Attributes

On Thursday, August 9, 2018 at 12:23:13 PM UTC+1, Krzysztof Koźmic wrote:
>
> Ah I see. So it's more about configuring the interceptors, rather than 
> selecting which methods to intercept and which interceptors to use for the 
> job?
>
> Sounds like you might want to have your interceptors implement 
> IOnBehalfAware 
> https://github.com/castleproject/Windsor/blob/master/docs/interceptors.md#ionbehalfaware-interface
>  
> to let you inspect the component model implementation for your attributes 
> there, cache the data and then apply appropriately during interception.
>
> On Thu, 9 Aug 2018 at 10:11 'Jordan' via Castle Project Users <
> castle-pro...@googlegroups.com > wrote:
>
>> Hello,
>>
>> Yes this is the context of Windsor as opposed to using just plain 
>> DynamicProxy. I am working on a MVC Web app with NHibernate 5.1.3.
>>
>> In the absence of an up to date NHibernate Facility I have created a very 
>> minimal OpenSessionInView implementation and a Transaction 
>> attribute/interceptor.
>>
>> I want the Transaction attribute to have a couple of properties, eg 
>> System.Data.IsolationLevel and maybe a ReadOnly boolean which will be set 
>> on the interceptor so it knows how to configure the Transaction.
>>
>> many thanks,
>> Jordan
>>
>>
>>
>>
>> On Wednesday, August 8, 2018 at 7:42:07 PM UTC+1, Krzysztof Koźmic wrote:
>>
>>> Hi,
>>>
>>> No need to apologise. Having re-read your question I think I 
>>> misunderstood what you wanted to do. Can you elaborate on how you want to 
>>> configure the interceptors with attributes? You mention a container, does 
>>> that mean your question is in the context of Windsor as opposed to using 
>>> just plain DynamicProxy?
>>>
>>> On Wed, 8 Aug 2018 at 17:30 'Jordan' via Castle Project Users <
>>> castle-pro...@googlegroups.com> wrote:
>>>
>> On Wednesday, August 8, 2018 at 4:16:53 PM UTC+1, Krzysztof Koźmic wrote:
>>>>>
>>>>> Yes, there is 
>>>>> http://kozmic.net/2009/02/14/castle-dynamic-proxy-tutorial-part-v-interceptorselector-fine-grained-control/
>>>>>
>>>>
>>>> Thanks for the reply! However, after one quick read I don't understand!
>>>>
>>>> By "Yes. there is" do you mean yes there is a better way to do this? 
>>>> I'm a bit confused because your example doesn't configure the interceptor 
>>>> for each call based on the properties of an attribute (or based on 
>>>> anything 
>>>> else).
>>>>
>>>> Really really sorry if I've missed something obvious.
>>>>
>>>> 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.
>>>>
>>> -- 
>>>
>>> sent from my phone
>>> Krzysztof
>>>
>> -- 
>> 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.
>>
> -- 
>
> sent from my phone
> Krzysztof
>

-- 
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: Intercepting method calls with an IInterceptorSelector

2018-08-09 Thread 'Jordan' via Castle Project Users
I am running my transactions at the application service level, not at the 
controller level.


On Thursday, August 9, 2018 at 12:26:06 PM UTC+1, Krzysztof Koźmic wrote:
>
> Separately from that, if that's about ASP.NET MVC controllers, wouldn't 
> IActionFilter make more sense than using DynamicProxy?
>
> On Thu, 9 Aug 2018 at 13:22 Krzysztof Koźmic  > wrote:
>
>> Ah I see. So it's more about configuring the interceptors, rather than 
>> selecting which methods to intercept and which interceptors to use for the 
>> job?
>>
>> Sounds like you might want to have your interceptors implement 
>> IOnBehalfAware 
>> https://github.com/castleproject/Windsor/blob/master/docs/interceptors.md#ionbehalfaware-interface
>>  
>> to let you inspect the component model implementation for your attributes 
>> there, cache the data and then apply appropriately during interception.
>>
>> On Thu, 9 Aug 2018 at 10:11 'Jordan' via Castle Project Users <
>> castle-pro...@googlegroups.com > wrote:
>>
>>> Hello,
>>>
>>> Yes this is the context of Windsor as opposed to using just plain 
>>> DynamicProxy. I am working on a MVC Web app with NHibernate 5.1.3.
>>>
>>> In the absence of an up to date NHibernate Facility I have created a 
>>> very minimal OpenSessionInView implementation and a Transaction 
>>> attribute/interceptor.
>>>
>>> I want the Transaction attribute to have a couple of properties, eg 
>>> System.Data.IsolationLevel and maybe a ReadOnly boolean which will be set 
>>> on the interceptor so it knows how to configure the Transaction.
>>>
>>> many thanks,
>>> Jordan
>>>
>>>
>>>
>>>
>>> On Wednesday, August 8, 2018 at 7:42:07 PM UTC+1, Krzysztof Koźmic wrote:
>>>
>>>> Hi,
>>>>
>>>> No need to apologise. Having re-read your question I think I 
>>>> misunderstood what you wanted to do. Can you elaborate on how you want to 
>>>> configure the interceptors with attributes? You mention a container, does 
>>>> that mean your question is in the context of Windsor as opposed to using 
>>>> just plain DynamicProxy?
>>>>
>>>> On Wed, 8 Aug 2018 at 17:30 'Jordan' via Castle Project Users <
>>>> castle-pro...@googlegroups.com> wrote:
>>>>
>>> On Wednesday, August 8, 2018 at 4:16:53 PM UTC+1, Krzysztof Koźmic wrote:
>>>>>>
>>>>>> Yes, there is 
>>>>>> http://kozmic.net/2009/02/14/castle-dynamic-proxy-tutorial-part-v-interceptorselector-fine-grained-control/
>>>>>>
>>>>>
>>>>> Thanks for the reply! However, after one quick read I don't understand!
>>>>>
>>>>> By "Yes. there is" do you mean yes there is a better way to do this? 
>>>>> I'm a bit confused because your example doesn't configure the interceptor 
>>>>> for each call based on the properties of an attribute (or based on 
>>>>> anything 
>>>>> else).
>>>>>
>>>>> Really really sorry if I've missed something obvious.
>>>>>
>>>>> 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.
>>>>>
>>>> -- 
>>>>
>>>> sent from my phone
>>>> Krzysztof
>>>>
>>> -- 
>>> 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.
>>>
>> -- 
>>
>> sent from my phone
>> Krzysztof
>>
> -- 
>
> sent from my phone
> Krzysztof
>

-- 
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: Intercepting method calls with an IInterceptorSelector

2018-08-09 Thread 'Jordan' via Castle Project Users
Hello,

Yes this is the context of Windsor as opposed to using just plain 
DynamicProxy. I am working on a MVC Web app with NHibernate 5.1.3.

In the absence of an up to date NHibernate Facility I have created a very 
minimal OpenSessionInView implementation and a Transaction 
attribute/interceptor.

I want the Transaction attribute to have a couple of properties, eg 
System.Data.IsolationLevel and maybe a ReadOnly boolean which will be set 
on the interceptor so it knows how to configure the Transaction.

many thanks,
Jordan




On Wednesday, August 8, 2018 at 7:42:07 PM UTC+1, Krzysztof Koźmic wrote:
>
> Hi,
>
> No need to apologise. Having re-read your question I think I misunderstood 
> what you wanted to do. Can you elaborate on how you want to configure the 
> interceptors with attributes? You mention a container, does that mean your 
> question is in the context of Windsor as opposed to using just plain 
> DynamicProxy?
>
> On Wed, 8 Aug 2018 at 17:30 'Jordan' via Castle Project Users <
> castle-pro...@googlegroups.com > wrote:
>
>> On Wednesday, August 8, 2018 at 4:16:53 PM UTC+1, Krzysztof Koźmic wrote:
>>>
>>> Yes, there is 
>>> http://kozmic.net/2009/02/14/castle-dynamic-proxy-tutorial-part-v-interceptorselector-fine-grained-control/
>>>
>>
>> Thanks for the reply! However, after one quick read I don't understand!
>>
>> By "Yes. there is" do you mean yes there is a better way to do this? I'm 
>> a bit confused because your example doesn't configure the interceptor for 
>> each call based on the properties of an attribute (or based on anything 
>> else).
>>
>> Really really sorry if I've missed something obvious.
>>
>> 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.
>>
> -- 
>
> sent from my phone
> Krzysztof
>

-- 
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: Intercepting method calls with an IInterceptorSelector

2018-08-08 Thread 'Jordan' via Castle Project Users
On Wednesday, August 8, 2018 at 4:16:53 PM UTC+1, Krzysztof Koźmic wrote:
>
> Yes, there is 
> http://kozmic.net/2009/02/14/castle-dynamic-proxy-tutorial-part-v-interceptorselector-fine-grained-control/
>

Thanks for the reply! However, after one quick read I don't understand!

By "Yes. there is" do you mean yes there is a better way to do this? I'm a 
bit confused because your example doesn't configure the interceptor for 
each call based on the properties of an attribute (or based on anything 
else).

Really really sorry if I've missed something obvious.

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.