예제 #1
0
        internal static ConversionClass ClassifyPredefinedConversion(Type TargetType, Type SourceType)
        {
            if (TargetType == SourceType)
            {
                return(ConversionClass.Identity);
            }
            TypeCode typeCode = Symbols.GetTypeCode(SourceType);
            TypeCode code2    = Symbols.GetTypeCode(TargetType);

            if (Symbols.IsIntrinsicType(typeCode) && Symbols.IsIntrinsicType(code2))
            {
                if ((Symbols.IsEnum(TargetType) && Symbols.IsIntegralType(typeCode)) && Symbols.IsIntegralType(code2))
                {
                    return(ConversionClass.Narrowing);
                }
                if ((typeCode == code2) && Symbols.IsEnum(SourceType))
                {
                    return(ConversionClass.Widening);
                }
                return(ClassifyIntrinsicConversion(code2, typeCode));
            }
            if (Symbols.IsCharArrayRankOne(SourceType) && Symbols.IsStringType(TargetType))
            {
                return(ConversionClass.Widening);
            }
            if (Symbols.IsCharArrayRankOne(TargetType) && Symbols.IsStringType(SourceType))
            {
                return(ConversionClass.Narrowing);
            }
            return(ClassifyPredefinedCLRConversion(TargetType, SourceType));
        }