private static ConditionResult ConvertToValueConditionAndVerify(List <object> objects, IValueCondition cond) { ConditionResult result = new ConditionResult() { Condition = cond }; var refValue = cond.ReferenceValue; if (refValue == null) { BH.Engine.Reflection.Compute.RecordNote($"A {cond.GetType().Name}'s {nameof(cond.ReferenceValue)} was null. Make sure this is intended.\nTo check for null/not null, consider using a {nameof(IsNull)} instead."); } ValueCondition valueCondition = cond.ToValueCondition(); ConditionResult valueCondRes = VerifyCondition(objects, valueCondition); result.FailedObjects = valueCondRes.FailedObjects; result.PassedObjects = valueCondRes.PassedObjects; result.Pattern = valueCondRes.Pattern; result.FailInfo = valueCondRes.FailInfo; return(result); }
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); }