Hi!
> 1. AbstractInvocation whould _not_ know about the field. The
> AbstractInvocation's code could be similar to this:
>
> protected AbstractInvocation(
> object target, object proxy, IInterceptor[] interceptors,
> Type targetType, MethodInfo targetMethod, object[]
> arguments,
> ref IInterceptor[] methodInterceptors, IInterceptorSelector
> selector)
> {
> Debug.Assert( selector != null, "if this .ctor is called
> selector must exist" );
> if (methodInterceptors == null)
> {
> methodInterceptors = selector.SelectInterceptors(
> targetType, targetMethod, interceptors ) ?? new IInterceptor[0];
> }
>
> this.proxy = proxy;
> this.target = target;
> this.interceptors = methodInterceptors;
> this.targetType = targetType;
> this.targetMethod = targetMethod;
> this.arguments = arguments;
> }
>
> all AbstractInvocation knows about is that it gets a ref IInterceptor[]
> parameter. I think it's cleaner than passing whole cache, and then
> havign to do lookup.
I think I like this implementation. What would you do about generic
methods? Still one field? Or use the generic arguments to
differentiate further? (That's why I suggested the Dictionary-based
separate cache - it would be more flexible in this regard. Although
you're of course right, we need to cache per instance, not static.)
And there is still another issue: it would actually be correct to pass
the result of "GetConcreteMethod" to IInterceptorSelector (this works
around a few bugs to always produce the correct MethodInfo for the
invoked method). However, this method has two drawbacks:
- It is expensive.
- It can only be called after the generic method arguments have been
set (ie. after the constructor).
The first issue can be mitigated by changing IInterceptorSelector to
take the IInvocation instead of its current Type + MethodInfo
combination. Then the selector can decide whether it wants the
"correct" behavior or the faster behavior.
The second would probably need a change in the constructor so that the
generic arguments are passed to the constructor instead of being set
separately.
Regards,
Fabian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Development List" 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-devel?hl=en
-~----------~----~----~----~------~----~------~--~---