Search code examples
castle-windsorcastlecastle-dynamicproxy

Overridding GetHashCode and Equals in Castle Dynamic Proxy 2.1 IModelInterceptorsSelector


I've read that in order to get caching and push performance when using an Interceptor Selector when using Castle Dynamic Proxy that I need to override GetType(), GetHashCode() and Equals()

Where can I find an example of or what would be the best, from a performing perspective, implementation?


Solution

  • you can't override GetType, it's not virtual.

    For the remaining ones, use the same technique you'd use for any other type. I generally make my selectors stateless, and implement the methods as this.GetType().GetHashCode() and This.GetType() == other.GetType()