Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetMethodBasedCoercionOperator()

static UnaryExpression System.Linq.Expressions.Expression< TDelegate >.GetMethodBasedCoercionOperator ( ExpressionType unaryType,
Expression< TDelegate > operand,
Type convertToType,
MethodInfo method )
inlinestaticprivateinherited

Definition at line 5095 of file Expression.cs.

5096 {
5098 ParameterInfo[] parametersCached = method.GetParametersCached();
5099 if (parametersCached.Length != 1)
5100 {
5101 throw Error.IncorrectNumberOfMethodCallArguments(method, "method");
5102 }
5104 {
5105 return new UnaryExpression(unaryType, operand, method.ReturnType, method);
5106 }
5107 if ((operand.Type.IsNullableType() || convertToType.IsNullableType()) && ParameterIsAssignable(parametersCached[0], operand.Type.GetNonNullableType()) && (TypeUtils.AreEquivalent(method.ReturnType, convertToType.GetNonNullableType()) || TypeUtils.AreEquivalent(method.ReturnType, convertToType)))
5108 {
5109 return new UnaryExpression(unaryType, operand, convertToType, method);
5110 }
5111 throw Error.OperandTypesDoNotMatchParameters(unaryType, method.Name);
5112 }
static bool AreEquivalent(Type t1, Type t2)
Definition TypeUtils.cs:664
static void ValidateOperator(MethodInfo method)
static bool ParameterIsAssignable(ParameterInfo pi, Type argType)

References System.Dynamic.Utils.TypeUtils.AreEquivalent(), System.Linq.Expressions.Error.IncorrectNumberOfMethodCallArguments(), System.Linq.Expressions.Error.OperandTypesDoNotMatchParameters(), System.Linq.Expressions.Expression< TDelegate >.ParameterIsAssignable(), and System.Linq.Expressions.Expression< TDelegate >.ValidateOperator().

Referenced by System.Linq.Expressions.Expression< TDelegate >.Convert(), and System.Linq.Expressions.Expression< TDelegate >.ConvertChecked().