/// <summary> /// Adjusts the given value to conform to the parameters specified maximums and minimums /// </summary> public static IComparable GetClosestValueInBounds(this ParameterAttribute attr, IComparable value) { if (attr.HasMinValue() && value.CompareTo(attr.MinValue) <= 0) { return((IComparable)attr.MinValue); } if (attr.HasMaxValue() && value.CompareTo(attr.MaxValue) >= 0) { return((IComparable)attr.MaxValue); } return(value); }
/// <summary> /// Does the parameter have a non-null maximum value? /// </summary> public static bool HasMaxValue(this ParameterAttribute attr) { return(attr.MaxValue != null); }
/// <summary> /// Does the parameter have a non-null default value? /// </summary> public static bool HasDefaultValue(this ParameterAttribute attr) { return(attr.DefaultValue != null); }