Search code examples
c#castle-windsoraopinterceptorcastle-dynamicproxy

Can I specify to Castle Windsor which virtual methods to override in a class proxy?


I have many virtual methods in a class, but only one should be intercepted, Can I tell Castle Windsor to override only that method so I dont have to do validation in the Intercept method?

Edit:

I use the IKernelEvents.ComponentRegistered event to choose which types get the interceptor.


Solution

    1. If you want to proxy just one method, use IProxyHook to pick which method you want to proxy.
    2. If you're modifying ComponentModel (and adding interceptors or proxy hooks is one such operation) use IContributeComponentModelConstructions for that. See the docs for more in depth explanation.