Search code examples
.netcastle-windsorcastle-dynamicproxy

Easiest way to check if method is auto-implemented by Castle DynamicProxy


I'm looking for the easiest way to check if a method on my proxy has been auto-implemented by DynamicProxy. That is, let's say when registering my component, I added some AdditionalInterfaces, and in my interceptor, I only want to intercept the method if that interface was auto-implemented on the proxy and will simply throw a NotImplementedException if I call .Proceed(). I can think of some crude ways to check this using the ComponentModel, but I was hoping there might be something easy/straightforward.

Thanks!


Solution

  • Use IProxyGenerationHook to only proxy the methods you want to intercept.