Ejemplo n.º 1
0
        private static bool IsValid(string value, double min, double max)
        {
            var divisor = 1d;

            if (max <= 1d && value.EndsWith("%"))
            {
                value   = value.Substring(0, value.Length - 1);
                divisor = 100d;
            }

            return(InvariantDouble.TryParse(value, out var result) && result / divisor > min && result / divisor < max);
        }
Ejemplo n.º 2
0
        private static double Clamp(string value, double min, double max, double def)
        {
            var divisor = 1d;

            if (value.EndsWith("%"))
            {
                value   = value.Substring(0, value.Length - 1);
                divisor = 100d;
            }

            return(InvariantDouble.TryParse(value, out var result)
                ? Clamp(result / divisor, min, max)
                : def);
        }