public override object GetValue() { if (_property == null) { return(null); } object instance = _target.GetValue(); if (NullHelper.IsNull(instance)) { return(null); } object result; try { result = _property.GetValue(instance); } catch (NQueryException) { throw; } catch (Exception ex) { throw ExceptionBuilder.PropertyBindingGetValueFailed(ex); } return(NullHelper.UnifyNullRepresentation(result)); }
public override object GetValue() { object expressionValue = _expression.GetValue(); if (_negated) { return(expressionValue != null); } else { return(expressionValue == null); } }
public override object GetValue() { object value = _operand.GetValue(); if (value == null || OperatorMethod == null) { return(null); } try { return(OperatorMethod.Invoke(null, new object[] { value })); } catch (TargetInvocationException ex) { throw ExceptionBuilder.UnaryOperatorFailed(Op, OperatorMethod, _operand.ExpressionType, value, ex.InnerException); } }
public override object GetValue() { if (_method == null) { return(null); } object targetValue = _target.GetValue(); if (NullHelper.IsNull(targetValue)) { return(null); } object[] argumentValues = new object[_arguments.Length]; for (int i = 0; i < argumentValues.Length; i++) { argumentValues[i] = _arguments[i].GetValue(); } object result; try { result = _method.Invoke(targetValue, argumentValues); } catch (TargetInvocationException ex) { // Special handling for target invocation since we are only // interested in the inner one. throw ExceptionBuilder.MethodBindingInvokeFailed(ex.InnerException); } catch (NQueryException) { throw; } catch (Exception ex) { throw ExceptionBuilder.MethodBindingInvokeFailed(ex); } return(NullHelper.UnifyNullRepresentation(result)); }
public override object GetValue() { object value = _expression.GetValue(); if (value == null) { return(null); } try { return(_convertMethod.Invoke(null, new object[] { value })); } catch (NQueryException) { throw; } catch (Exception ex) { throw ExceptionBuilder.CastingOperatorFailed(ex); } }
public override object GetValue() { if (_whenExpressions == null || _thenExpressions == null || _whenExpressions.Length != _thenExpressions.Length) { return(null); } if (_inputExpression != null) { // Simple case object inputValue = _inputExpression.GetValue(); if (inputValue == null) { if (_elseExpression == null) { return(null); } else { return(_elseExpression.GetValue()); } } for (int i = 0; i < _whenExpressions.Length; i++) { object whenValue = _whenExpressions[i].GetValue(); if (whenValue != null && Equals(inputValue, whenValue)) { return(_thenExpressions[i].GetValue()); } } if (_elseExpression != null) { return(_elseExpression.GetValue()); } return(null); } else { // Searched case for (int i = 0; i < _whenExpressions.Length; i++) { object whenConditionValue = _whenExpressions[i].GetValue(); if (whenConditionValue != null && Convert.ToBoolean(whenConditionValue, CultureInfo.InvariantCulture)) { return(_thenExpressions[i].GetValue()); } } if (_elseExpression != null) { return(_elseExpression.GetValue()); } return(null); } }
public override object GetValue() { if (OperatorMethod == null) { return(null); } if (_op != BinaryOperator.LogicalAnd && _op != BinaryOperator.LogicalOr) { // Normal evaluation. // // In this case the whole expression is null when // left or right is null. object left = _left.GetValue(); if (left == null) { return(null); } object right = _right.GetValue(); if (right == null) { return(null); } try { return(OperatorMethod.Invoke(null, new object[] { left, right })); } catch (TargetInvocationException ex) { throw ExceptionBuilder.BinaryOperatorFailed(Op, OperatorMethod, _left.ExpressionType, _right.ExpressionType, left, right, ex.InnerException); } } else { // Operator is either LogicalAnd or LogicalOr. // // Special handling for three-state boolean logic and short-circuit // boolean evaluation. // // ATTENTION: All binary operators will return null when any operand is // is null. Logical operations are different in this point. // Sometimes boolean operators will return TRUE or FALSE though // an operand was null. // // See tables for details. // // AND | F | T | N OR | F | T | N // ----+---+---+-- ---+---+---+-- // F | F | F | F F | F | T | N // T | F | T | N T | T | T | T // N | F | N | N N | N | T | N object left = _left.GetValue(); if (left != null) { // Special handling to allow short-circuit boolean evaluation. bool leftAsBool = Convert.ToBoolean(left, CultureInfo.InvariantCulture); if (_op == BinaryOperator.LogicalAnd && !leftAsBool) { return(false); } if (_op == BinaryOperator.LogicalOr && leftAsBool) { return(true); } } object right = _right.GetValue(); if (left == null && right == null) { return(null); } if (left != null && right != null) { bool leftAsBool = Convert.ToBoolean(left, CultureInfo.InvariantCulture); bool rightAsBool = Convert.ToBoolean(right, CultureInfo.InvariantCulture); if (_op == BinaryOperator.LogicalAnd) { return(leftAsBool && rightAsBool); } else { return(leftAsBool || rightAsBool); } } else if (left != null) { // left != null && right == null bool leftAsBool = Convert.ToBoolean(left, CultureInfo.InvariantCulture); if (_op == BinaryOperator.LogicalAnd) { if (leftAsBool) { return(null); } else { return(false); } } else { if (leftAsBool) { return(true); } else { return(null); } } } else { // left == null && right != null bool rightAsBool = Convert.ToBoolean(right, CultureInfo.InvariantCulture); if (_op == BinaryOperator.LogicalAnd) { if (rightAsBool) { return(null); } else { return(false); } } else { if (rightAsBool) { return(true); } else { return(null); } } } } }
public override object GetValue() { return(_expressionNode.GetValue()); }