예제 #1
0
        public Expression MakeTestForTypes(Type[] types, int index)
        {
            Expression test = MakeTypeTest(types[index], index);

            if (index < types.Length - 1)
            {
                Expression nextTests = MakeTestForTypes(types, index + 1);
                if (ConstantCheck.Check(test, true))
                {
                    return(nextTests);
                }
                else if (ConstantCheck.Check(nextTests, true))
                {
                    return(test);
                }
                else
                {
                    return(Ast.AndAlso(test, nextTests));
                }
            }
            else
            {
                return(test);
            }
        }
예제 #2
0
파일: TypeUtils.cs 프로젝트: stantoxt/dlr
        internal static bool CanAssign(Type to, Expression from) {
            if (CanAssign(to, from.Type)) return true;

            if (to.IsValueType() && 
                to.IsGenericType() && 
                to.GetGenericTypeDefinition() == typeof(Nullable<>) && 
                ConstantCheck.Check(from, null)) {
                return true;
            }

            return false;
        }