static private OperandTypesDoNotMatchParameters ( object p0, object p1 ) : Exception | ||
p0 | object | |
p1 | object | |
return | Exception |
private static Type ValidateConversion(CSharpExpressionType nodeType, Type inputType, LambdaExpression conversion) { var invoke = conversion.Type.GetMethod("Invoke"); var invokeParameters = invoke.GetParametersCached(); if (invokeParameters.Length != 1) { throw LinqError.IncorrectNumberOfMethodCallArguments(conversion); } if (!TypeUtils.AreEquivalent(invokeParameters[0].ParameterType, inputType)) { throw LinqError.OperandTypesDoNotMatchParameters(nodeType, conversion.ToString()); } return(invoke.ReturnType); }
//CONFORMING private static UnaryExpression GetMethodBasedCoercionOperator(ExpressionType unaryType, Expression operand, Type convertToType, MethodInfo method) { System.Diagnostics.Debug.Assert(method != null); ValidateOperator(method); ParameterInfo[] pms = method.GetParametersCached(); if (pms.Length != 1) { throw Error.IncorrectNumberOfMethodCallArguments(method); } if (ParameterIsAssignable(pms[0], operand.Type) && method.ReturnType == convertToType) { return(new UnaryExpression(unaryType, operand, method.ReturnType, method)); } // check for lifted call if ((TypeUtils.IsNullableType(operand.Type) || TypeUtils.IsNullableType(convertToType)) && ParameterIsAssignable(pms[0], TypeUtils.GetNonNullableType(operand.Type)) && method.ReturnType == TypeUtils.GetNonNullableType(convertToType)) { return(new UnaryExpression(unaryType, operand, convertToType, method)); } throw Error.OperandTypesDoNotMatchParameters(unaryType, method.Name); }