private bool CompareInt(string value, ValuePathMatcher matcher) { // This one is freeform based on the input so we will retrun false if it is not parsable if (!int.TryParse(value, out int dValue)) { return(false); } // We will throw an exception if match value is not a numeric value. This is a developer // error. int dMatchValue = int.Parse(matcher.matchValue); switch (matcher.comparisonMethod) { case ComparisonMethod.Equals: return(dValue == dMatchValue); case ComparisonMethod.NotEquals: return(dValue != dMatchValue); case ComparisonMethod.Greater: return(dValue > dMatchValue); case ComparisonMethod.Less: return(dValue < dMatchValue); case ComparisonMethod.GreaterThanOrEqualTo: return(dValue >= dMatchValue); case ComparisonMethod.LessThanOrEqualTo: return(dValue <= dMatchValue); } return(false); }
private bool CompareDouble(string value, ValuePathMatcher matcher) { // This one is freeform based on the input so we will retrun false if it is not parsable if (!double.TryParse(value, out double dValue)) { return(false); } // We will throw an exception if match value is not a numeric value. This is a developer // error. double dMatchValue = double.Parse(matcher.matchValue); switch (matcher.comparisonMethod) { case ComparisonMethod.Equals: return(Math.Abs(dValue - dMatchValue) < matcher.floatingPointComparisonTolerance); case ComparisonMethod.NotEquals: return(Math.Abs(dValue - dMatchValue) > matcher.floatingPointComparisonTolerance); case ComparisonMethod.Greater: return(dValue > dMatchValue); case ComparisonMethod.Less: return(dValue < dMatchValue); case ComparisonMethod.GreaterThanOrEqualTo: return(dValue >= dMatchValue); case ComparisonMethod.LessThanOrEqualTo: return(dValue <= dMatchValue); } return(false); }