System.Linq.Expressions.Expression.GetUserDefinedUnaryOperator C# (CSharp) Method

GetUserDefinedUnaryOperator() private static method

private static GetUserDefinedUnaryOperator ( ExpressionType unaryType, string name, Expression operand ) : UnaryExpression
unaryType ExpressionType
name string
operand Expression
return UnaryExpression
        private static UnaryExpression GetUserDefinedUnaryOperator(ExpressionType unaryType, string name, Expression operand)
        {
            Type operandType = operand.Type;
            Type[] types = new Type[] { operandType };
            Type nnOperandType = operandType.GetNonNullableType();
            MethodInfo method = nnOperandType.GetAnyStaticMethodValidated(name, types);
            if (method != null)
            {
                return new UnaryExpression(unaryType, operand, method.ReturnType, method);
            }
            // try lifted call
            if (operandType.IsNullableType())
            {
                types[0] = nnOperandType;
                method = nnOperandType.GetAnyStaticMethodValidated(name, types);
                if (method != null && method.ReturnType.GetTypeInfo().IsValueType && !method.ReturnType.IsNullableType())
                {
                    return new UnaryExpression(unaryType, operand, method.ReturnType.GetNullableType(), method);
                }
            }
            return null;
        }
Expression