public static ValueCondition ToValueCondition(this IValueCondition iValueCondition)
        {
            ValueCondition valueCond = iValueCondition as ValueCondition;

            if (valueCond != null)
            {
                return(valueCond);
            }

            ValueComparisons valueComparison = ValueComparisons.EqualTo;

            switch (iValueCondition.GetType().Name)
            {
            case (nameof(IsEqualTo)):
                valueComparison = ValueComparisons.EqualTo;
                break;

            case (nameof(IsLessThan)):
                valueComparison = ValueComparisons.LessThan;
                break;

            case (nameof(IsLessThanOrEqualTo)):
                valueComparison = ValueComparisons.LessThanOrEqualTo;
                break;

            case (nameof(IsGreaterThan)):
                valueComparison = ValueComparisons.GreaterThan;
                break;

            case (nameof(IsGreaterThanOrEqualTo)):
                valueComparison = ValueComparisons.GreaterThanOrEqualTo;
                break;
            }

            ValueCondition valueCondition = new ValueCondition()
            {
                Clause         = iValueCondition.Clause,
                Comment        = iValueCondition.Comment,
                Comparison     = valueComparison,
                Name           = iValueCondition.Name,
                Source         = iValueCondition.Source,
                ReferenceValue = iValueCondition.ReferenceValue,
                Tolerance      = iValueCondition.Tolerance,
                PropertyName   = iValueCondition.PropertyName
            };

            return(valueCondition);
        }
        public string ToPythonString()
        {
            var ret = "(" + string.Join("&&", ValueComparisons.Select(vc => vc.ToPythonString())) + ")";

            return(ret);
        }
 public override int GetHashCode()
 {
     return(ValueComparisons.Aggregate(0, (current, k) => current ^ k.GetHashCode()));
 }
Esempio n. 4
0
        private static bool NumericalComparison(double numericalValue, double referenceNumValue, double numTolerance, ValueComparisons comparison)
        {
            bool passed;

            switch (comparison)
            {
            case (ValueComparisons.EqualTo):
                passed = referenceNumValue - numTolerance <= numericalValue && numericalValue <= referenceNumValue + numTolerance;
                break;

            case (ValueComparisons.LessThan):
                passed = numericalValue < referenceNumValue + numTolerance;
                break;

            case (ValueComparisons.LessThanOrEqualTo):
                passed = numericalValue <= referenceNumValue + numTolerance;
                break;

            case (ValueComparisons.GreaterThanOrEqualTo):
                passed = numericalValue >= referenceNumValue - numTolerance;
                break;

            case (ValueComparisons.GreaterThan):
                passed = numericalValue > referenceNumValue - numTolerance;
                break;

            default:
                passed = false;
                break;
            }

            return(passed);
        }