public static bool TryGenerateLinqDelegate <TLeft, TRight, TResult>(ExpressionType operatorType, out Func <TLeft, TRight, TResult> function, out ValidationError validationError)
        {
            function        = null;
            validationError = null;

            ParameterExpression leftParameter  = Expression.Parameter(typeof(TLeft), "left");
            ParameterExpression rightParameter = Expression.Parameter(typeof(TRight), "right");

            try
            {
                BinaryExpression binaryExpression = Expression.MakeBinary(operatorType, leftParameter, rightParameter);

                Expression expressionToCompile = OperatorPermissionHelper.InjectReflectionPermissionIfNecessary(binaryExpression.Method, binaryExpression);
                Expression <Func <TLeft, TRight, TResult> > lambdaExpression = Expression.Lambda <Func <TLeft, TRight, TResult> >(expressionToCompile, leftParameter, rightParameter);
                function = lambdaExpression.Compile();

                return(true);
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }

                validationError = new ValidationError(e.Message);
                return(false);
            }
        }
        public static bool TryGenerateLinqDelegate <TOperand, TResult>(ExpressionType operatorType, out Func <TOperand, TResult> operation, out ValidationError validationError)
        {
            operation       = null;
            validationError = null;

            ParameterExpression operandParameter = Expression.Parameter(typeof(TOperand), "operand");

            try
            {
                UnaryExpression unaryExpression     = Expression.MakeUnary(operatorType, operandParameter, typeof(TResult));
                Expression      expressionToCompile = OperatorPermissionHelper.InjectReflectionPermissionIfNecessary(unaryExpression.Method, unaryExpression);
                Expression <Func <TOperand, TResult> > lambdaExpression = Expression.Lambda <Func <TOperand, TResult> >(expressionToCompile, operandParameter);
                operation = lambdaExpression.Compile();
                return(true);
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }

                validationError = new ValidationError(e.Message);
                return(false);
            }
        }