public bool ValidateConstantConstraints(Dictionary <string, string> constraints) { if (!constantConstraintsChecked) { constantConstraintsValid = true; if (rule.constantConstraints != null) { for (int i = 0; i < rule.constantConstraints.Count; i++) { Rule.ConstantConstraint constantConstraint = rule.constantConstraints[i]; string text = (constraints != null) ? constraints.TryGetValue(constantConstraint.key, "") : ""; float result = 0f; float result2 = 0f; bool flag = !text.NullOrEmpty() && !constantConstraint.value.NullOrEmpty() && float.TryParse(text, out result) && float.TryParse(constantConstraint.value, out result2); bool flag2; switch (constantConstraint.type) { case Rule.ConstantConstraint.Type.Equal: flag2 = text.EqualsIgnoreCase(constantConstraint.value); break; case Rule.ConstantConstraint.Type.NotEqual: flag2 = !text.EqualsIgnoreCase(constantConstraint.value); break; case Rule.ConstantConstraint.Type.Less: flag2 = (flag && result < result2); break; case Rule.ConstantConstraint.Type.Greater: flag2 = (flag && result > result2); break; case Rule.ConstantConstraint.Type.LessOrEqual: flag2 = (flag && result <= result2); break; case Rule.ConstantConstraint.Type.GreaterOrEqual: flag2 = (flag && result >= result2); break; default: Log.Error("Unknown ConstantConstraint type: " + constantConstraint.type); flag2 = false; break; } if (!flag2) { constantConstraintsValid = false; break; } } } constantConstraintsChecked = true; } return(constantConstraintsValid); }
public bool ValidateConstantConstraints(Dictionary <string, string> constraints) { if (!constantConstraintsChecked) { constantConstraintsValid = true; if (rule.constantConstraints != null) { for (int i = 0; i < rule.constantConstraints.Count; i++) { Rule.ConstantConstraint constantConstraint = rule.constantConstraints[i]; string a = (constraints == null) ? string.Empty : constraints.TryGetValue(constantConstraint.key, string.Empty); if (a == constantConstraint.value != constantConstraint.equality) { constantConstraintsValid = false; break; } } } constantConstraintsChecked = true; } return(constantConstraintsValid); }
public bool ValidateConstantConstraints(Dictionary <string, string> constraints) { if (!this.constantConstraintsChecked) { this.constantConstraintsValid = true; if (this.rule.constantConstraints != null) { for (int i = 0; i < this.rule.constantConstraints.Count; i++) { Rule.ConstantConstraint constantConstraint = this.rule.constantConstraints[i]; string a = (constraints == null) ? "" : constraints.TryGetValue(constantConstraint.key, ""); if (a == constantConstraint.value != constantConstraint.equality) { this.constantConstraintsValid = false; break; } } } this.constantConstraintsChecked = true; } return(this.constantConstraintsValid); }