覆盖城堡动态代理2.1中的GetHashCode和等于IModelInterceptorsSelector

问题描述:

我读过,为了获得缓存和推送时使用拦截器选择器时使用城堡动态代理,我需要覆盖GetType(),GetHashCode()和等于()覆盖城堡动态代理2.1中的GetHashCode和等于IModelInterceptorsSelector

从哪里可以找到一个示例或什么是最好的,从执行的角度来看,实现?

你不能覆盖GetType,它不是虚拟的。

对于其余的,使用与其他类型相同的技巧。 我一般让我选择无状态,并实现方法为this.GetType().GetHashCode()This.GetType() == other.GetType()

+0

对于无状态选择的东西这么简单: 公众覆盖布尔等于(obj对象) { 回报this.GetType()== OBJ。的GetType(); } public override int GetHashCode() { return this.GetType()。GetHashCode(); } – detroitpro 2010-07-06 15:50:23