public bool Matches(ValueEval x) { int testValue = 0; if (x is StringEval) { if (true) { // Change to false to observe more intuitive behaviour // Note - Unlike with numbers, it seems that COUNTA never Matches // bool values when the tarGet(x) Is a string return(false); } StringEval se = (StringEval)x; bool? val = ParseBoolean(se.StringValue); if (val == null) { // x is text that is not a boolean return(false); } testValue = BoolToInt(val); } else if (x is BoolEval) { BoolEval be = (BoolEval)x; testValue = BoolToInt(be.BooleanValue); } else { return(false); } return(_operator.Evaluate(testValue - _value)); }
public bool Matches(ValueEval x) { double testValue; if (x is StringEval) { // if the tarGet(x) Is a string, but Parses as a number // it may still Count as a match StringEval se = (StringEval)x; double val = OperandResolver.ParseDouble(se.StringValue); if (double.IsNaN(val)) { // x Is text that Is not a number return(false); } testValue = val; } else if (x is NumberEval) { NumberEval ne = (NumberEval)x; testValue = ne.NumberValue; } else { return(false); } return(_operator.Evaluate(testValue.CompareTo(_value))); }
public bool Matches(ValueEval x) { if (x is BlankEval) { switch (_operator.Code) { case CmpOp.NONE: case CmpOp.EQ: return(_value.Length == 0); } // no other criteria matches a blank cell return(false); } if (!(x is StringEval)) { // must always be string // even if match str is wild, but contains only digits // e.g. '4*7', NumberEval(4567) does not match return(false); } String testedValue = ((StringEval)x).StringValue; if ((testedValue.Length < 1 && _value.Length < 1) || _value == "<>") { // odd case: criteria '=' behaves differently to criteria '' switch (_operator.Code) { case CmpOp.NONE: return(true); case CmpOp.EQ: return(false); case CmpOp.NE: return(true); } return(false); } if (_pattern != null) { return(_operator.Evaluate(_pattern.IsMatch(testedValue))); } return(_operator.Evaluate(testedValue.CompareTo(_value))); }
protected bool Evaluate(int cmpResult) { return(_operator.Evaluate(cmpResult)); }