protected override bool ValidateNewValueT(T newValue) { if (ScalarProperty <T> .IsLessThan(newValue, this.minValue)) { return(false); } if (ScalarProperty <T> .IsGreaterThan(newValue, this.maxValue)) { return(false); } return(base.ValidateNewValueT(newValue)); }
internal ScalarProperty(object name, T defaultValue, T minValue, T maxValue, bool readOnly, ValueValidationFailureResult vvfResult) : base(name, defaultValue, readOnly, vvfResult) { if (ScalarProperty <T> .IsLessThan(maxValue, minValue)) { throw new ArgumentOutOfRangeException("maxValue < minValue"); } if (ScalarProperty <T> .IsLessThan(defaultValue, minValue)) { throw new ArgumentOutOfRangeException("defaultValue < minValue"); } if (ScalarProperty <T> .IsGreaterThan(defaultValue, maxValue)) { throw new ArgumentOutOfRangeException("defaultValue > maxValue"); } this.minValue = minValue; this.maxValue = maxValue; }
public static T Clamp(T value, T min, T max) { T local = value; if (ScalarProperty <T> .IsGreaterThan(min, max)) { throw new ArgumentOutOfRangeException("min must be less than or equal to max"); } if (ScalarProperty <T> .IsGreaterThan(value, max)) { local = max; } if (ScalarProperty <T> .IsLessThan(value, min)) { local = min; } return(local); }
public static bool IsLessThan(ScalarProperty <T> lhs, ScalarProperty <T> rhs) => ScalarProperty <T> .IsLessThan(lhs.Value, rhs.Value);
public bool IsLessThan(ScalarProperty <T> rhs) => ScalarProperty <T> .IsLessThan((ScalarProperty <T>) this, rhs);