public static int CalculateArgumentScore(Type paramType, Type argType)
{
if (null == argType)
{
if (paramType.IsValueType) return -1;
return CandidateMethod.ExactMatchScore;
}
else
{
if (paramType == argType) return CandidateMethod.ExactMatchScore;
if (paramType.IsAssignableFrom(argType)) return CandidateMethod.UpCastScore;
if (argType.IsAssignableFrom(paramType)) return CandidateMethod.DowncastScore;
if (IsNumericPromotion(paramType, argType))
{
if (NumericTypes.IsWideningPromotion(paramType, argType)) return WideningPromotion;
return CandidateMethod.NarrowingPromotion;
}
MethodInfo conversion = RuntimeServices.FindImplicitConversionOperator(argType, paramType);
if (null != conversion) return CandidateMethod.ImplicitConversionScore;
}
return -1;
}