IsSameOrSubclass() public static method

public static IsSameOrSubclass ( Type type, Type subType ) : bool
type Type
subType Type
return bool
Example #1
0
        // Attempts to auto-quote the expression tree. Returns true if it succeeded, false otherwise.
        public static bool TryQuote(Type parameterType, ref Expression argument)
        {
            // We used to allow quoting of any expression, but the behavior of
            // quote (produce a new tree closed over parameter values), only
            // works consistently for lambdas
            Type quoteable = typeof(LambdaExpression);

            if (TypeUtils.IsSameOrSubclass(quoteable, parameterType) &&
                parameterType.IsAssignableFrom(argument.GetType()))
            {
                argument = Expression.Quote(argument);
                return(true);
            }
            return(false);
        }