Boo.Lang.Runtime.CandidateMethod.CalculateArgumentScore C# (CSharp) Метод

CalculateArgumentScore() публичный статический Метод

public static CalculateArgumentScore ( Type paramType, Type argType ) : int
paramType System.Type
argType System.Type
Результат int
        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;
        }

Usage Example

Пример #1
0
        private bool CalculateCandidateArgumentScore(CandidateMethod candidateMethod, int argumentIndex, Type paramType)
        {
            int score = CandidateMethod.CalculateArgumentScore(paramType, _arguments[argumentIndex]);

            if (score < 0)
            {
                return(false);
            }

            candidateMethod.ArgumentScores[argumentIndex] = score;
            return(true);
        }
All Usage Examples Of Boo.Lang.Runtime.CandidateMethod::CalculateArgumentScore