public int CompareEqualParameters(MethodTarget other) { // Prefer normal methods over explicit interface implementations if (other.Method.IsPrivate && !this.Method.IsPrivate) { return(+1); } if (this.Method.IsPrivate && !other.Method.IsPrivate) { return(-1); } // Prefer non-generic methods over generic methods if (Method.IsGenericMethod) { if (!other.Method.IsGenericMethod) { return(-1); } else { //!!! Need to support selecting least generic method here return(0); } } else if (other.Method.IsGenericMethod) { return(+1); } //prefer methods without out params over those with them switch (Compare(_returnBuilder.CountOutParams, other._returnBuilder.CountOutParams)) { case 1: return(-1); case -1: return(1); } //prefer methods using earlier conversions rules to later ones for (int i = Int32.MaxValue; i >= 0;) { int maxPriorityThis = FindMaxPriority(this._argBuilders, i); int maxPriorityOther = FindMaxPriority(other._argBuilders, i); if (maxPriorityThis < maxPriorityOther) { return(+1); } if (maxPriorityOther < maxPriorityThis) { return(-1); } i = maxPriorityThis - 1; } return(0); }
public int CompareEqualParameters(MethodTarget other) { // Prefer normal methods over explicit interface implementations if (other.Method.IsPrivate && !this.Method.IsPrivate) return +1; if (this.Method.IsPrivate && !other.Method.IsPrivate) return -1; // Prefer non-generic methods over generic methods if (Method.IsGenericMethod) { if (!other.Method.IsGenericMethod) { return -1; } else { //!!! Need to support selecting least generic method here return 0; } } else if (other.Method.IsGenericMethod) { return +1; } //prefer methods without out params over those with them switch (Compare(_returnBuilder.CountOutParams, other._returnBuilder.CountOutParams)) { case 1: return -1; case -1: return 1; } //prefer methods using earlier conversions rules to later ones for (int i = Int32.MaxValue; i >= 0; ) { int maxPriorityThis = FindMaxPriority(this._argBuilders, i); int maxPriorityOther = FindMaxPriority(other._argBuilders, i); if (maxPriorityThis < maxPriorityOther) return +1; if (maxPriorityOther < maxPriorityThis) return -1; i = maxPriorityThis - 1; } return 0; }