> The way proxy generation works now, is that proxy type is generated based on 
> three elements:
> - ProxyGenerationOptions
> - targetType
> - proxied interface and additional interfaces
>
> the interceptors arent part of the equation, so you cant preselect them at 
> generation time, because for one proxy type you can have different sets of 
> interceptors.

I know. But you could select whether to intercept (at all) or not. I
think proxying would be more efficient if we could choose not to proxy
things like ToString, Equals, GetHashCode, etc when we know beforehand
they aren't needed. But OTOH, maybe DP isn't used in such scenarios
anyway.

> The runtime selection has its advantages IMHO and its a more elegant solution 
> than delegating interceptor. At least if I understand correctly the idea 
> behind that interceptor.
> Could you maybe provide some code on how you think that interceptor should 
> work? The way I see it, it would be really hackish.

public class SelectingInterceptor : IInterceptor
{
  private IInterceptor[] nestedInterceptors;
  private IInterceptorSelector selector;

  public SelectingInterceptor (IInterceptor[] nestedInterceptors,
IInterceptorSelector selector)
  {
    ...
  }

  public void Intercept (IInvocation invocation)
  {
    var selectedInterceptors = selector.SelectInterceptors
(invocation.TargetType, invocation.Method);
    if (selectedInterceptors != null && selectedInterceptors.Length > 0)
      selectedInterceptor.Intercept (invocation);
    else
      invocation.Proceed();
  }
}

(Compiled by my head only.)

Caching based on the MethodInfo could be added if needed. Usage-wise,
the thing feels just the same, but from the point of view of DP, it's
much simpler.

(One could also change the interface of IInterceptorSelector a little:
maybe pass the whole IInvocation, then one could select based on the
call arguments. And is it really necessary to return an array? Maybe a
single returned IInterceptor would be enough.)

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

Reply via email to