>>> [email protected] 2008-12-17 15:07 >>>

> 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.

There's a IProxyGenerationHook that does just that.

check the bool ShouldInterceptMethod(Type type, MethodInfo memberInfo); method


> 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.)

You are basically repeating the Proceed method's implementation from Abstract 
Invocation here.

Also, think about how SelectingInterceptor would be created? It would have to 
be the only one interceptor in the proxy?
As I said... it's hackish, and adds complexity, not removes it.

Best regards
Krzysztof

Best regards,
Fabian





CONFIDENTIALITY NOTICE
This message is intended exclusively for the individual or entity to which it 
is addressed. This communication may contain information that is proprietary, 
privileged, confidential or otherwise legally exempt from disclosure. If you 
are not the named addressee, you are not authorized to read, print, retain, 
copy or disseminate this message or any part of it. If you have received this 
message in error, please delete all copies of this message and notify the 
sender immediately by return mail or fax ATSI S.A.(+4812) 285 36 04.
Any email attachment may contain software viruses which could damage your own 
computer system. Whilst reasonable precaution has been taken to minimise this 
risk, we cannot accept liability for any damage which you sustain as a result 
of software viruses. You should therefore carry out your own virus checks 
before opening any attachments.


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