brilliant! thanks! I can go to sleep now :) Will try it out tomorrow!

2011/1/29 Krzysztof Koźmic <[email protected]>:
> Actually I think ComponentModel construction contributor would be more
> appropriate here (doco:
> http://stw.castleproject.org/Windsor.ComponentModel-construction-contributors.ashx
> )
> You can set hook via the following code in the contributor
>
> var proxyOptions = ProxyUtil.ObtainProxyOptions(model, true);
> proxyOptions.Hook = new InstanceReference<IProxyGenerationHook>(yourHook);
>
> HTH,
> Krzysztof
>
> On 29/01/2011 12:11 PM, Seif Attar wrote:
>>
>> Hello,
>>
>> SharpArchitectureContrib currently has a logging facility, that works by:
>> 1. Handling KernelComponentRegistered and adding the LogInterceptor if
>> the class has the LogAttribute decorated on it, its assembly or any of
>> its methods.
>> 2. In the interceptor Intercept implementaion it checks if the current
>> method being intercepted, its class or its assembly has the attribute,
>> and logs accordingly.
>>
>> I don't like the fact that all this reflection happen, and after
>> reading the docs and Krzysztof Koźmic's tutorial I decided to replace
>> this with selector and hook, I think I need to replace 1 with a
>> IModelInterceptorsSelector (I got this part working) and 2 with
>> ProxyGenerationHook, which I can't figure out how to hook up!
>>
>> in the facility, I do
>>
>> this.Kernel.ProxyFactory.AddInterceptorSelector(LoggingInteceptorSelector());
>>
>> and in the ModelInterceptorsSelector:
>>
>> public bool HasInterceptors(ComponentModel model)
>>         {//check the service and implementaion, since the Log
>> attribute might be declared on either
>>             return
>> AttributeExtractor<T>.ShouldInterceptType(model.Implementation) ||
>>                    (model.Implementation != model.Service&&
>> AttributeExtractor<T>.ShouldInterceptType(model.Service));
>>         }
>>
>> public InterceptorReference[] SelectInterceptors(ComponentModel model,
>> InterceptorReference[] interceptors)
>>         {
>>             var selectedInterceptors = new
>> InterceptorReference[interceptors.Length + 1];
>>             interceptors.CopyTo(selectedInterceptors, 0);
>>             selectedInterceptors[selectedInterceptors.Length - 1] =
>>                 new InterceptorReference(typeof(LogInterceptor).Name);
>>             return selectedInterceptors;
>>         }
>>
>> Where can I add ProxyGenerationHook? or am I going at this the wrong
>> way? suggestions?
>>
>> Thanks,
>> Seif
>>
>
> --
> 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