Ejemplo n.º 1
0
        private static void updateCriteriaRange(ref FilterCriteria.OptionalRange <double> range, string op, double value, double tolerance = 0.05)
        {
            switch (op)
            {
            default:
                return;

            case "=":
            case ":":
                range.Min = value - tolerance;
                range.Max = value + tolerance;
                break;

            case ">":
                range.Min = value + tolerance;
                break;

            case ">=":
            case ">:":
                range.Min = value - tolerance;
                break;

            case "<":
                range.Max = value - tolerance;
                break;

            case "<=":
            case "<:":
                range.Max = value + tolerance;
                break;
            }
        }
Ejemplo n.º 2
0
        private static bool tryUpdateCriteriaRange(ref FilterCriteria.OptionalRange <double> range, Operator op, double value, double tolerance = 0.05)
        {
            switch (op)
            {
            default:
                return(false);

            case Operator.Equal:
                range.Min = value - tolerance;
                range.Max = value + tolerance;
                break;

            case Operator.Greater:
                range.Min = value + tolerance;
                break;

            case Operator.GreaterOrEqual:
                range.Min = value - tolerance;
                break;

            case Operator.Less:
                range.Max = value - tolerance;
                break;

            case Operator.LessOrEqual:
                range.Max = value + tolerance;
                break;
            }

            return(true);
        }
Ejemplo n.º 3
0
        private void updateCriteriaRange(ref FilterCriteria.OptionalRange <double> range, string op, double value, double tolerance = 0.05)
        {
            updateCriteriaRange(ref range, op, value);

            switch (op)
            {
            case "=":
            case ":":
                range.Min = value - tolerance;
                range.Max = value + tolerance;
                break;
            }
        }
Ejemplo n.º 4
0
        private void updateCriteriaRange <T>(ref FilterCriteria.OptionalRange <T> range, string op, T value)
            where T : struct, IComparable
        {
            switch (op)
            {
            default:
                return;

            case "=":
            case ":":
                range.IsInclusive = true;
                range.Min         = value;
                range.Max         = value;
                break;

            case ">":
                range.IsInclusive = false;
                range.Min         = value;
                break;

            case ">=":
            case ">:":
                range.IsInclusive = true;
                range.Min         = value;
                break;

            case "<":
                range.IsInclusive = false;
                range.Max         = value;
                break;

            case "<=":
            case "<:":
                range.IsInclusive = true;
                range.Max         = value;
                break;
            }
        }
Ejemplo n.º 5
0
        private static bool tryUpdateCriteriaRange <T>(ref FilterCriteria.OptionalRange <T> range, Operator op, T value)
            where T : struct
        {
            switch (op)
            {
            default:
                return(false);

            case Operator.Equal:
                range.IsLowerInclusive = range.IsUpperInclusive = true;
                range.Min = value;
                range.Max = value;
                break;

            case Operator.Greater:
                range.IsLowerInclusive = false;
                range.Min = value;
                break;

            case Operator.GreaterOrEqual:
                range.IsLowerInclusive = true;
                range.Min = value;
                break;

            case Operator.Less:
                range.IsUpperInclusive = false;
                range.Max = value;
                break;

            case Operator.LessOrEqual:
                range.IsUpperInclusive = true;
                range.Max = value;
                break;
            }

            return(true);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Attempts to parse a keyword filter of type <typeparamref name="T"/>,
 /// from the specified <paramref name="op"/> and <paramref name="val"/>.
 /// If <paramref name="val"/> can be parsed into <typeparamref name="T"/> using <paramref name="parseFunction"/>, the function returns <c>true</c>
 /// and the resulting range constraint is stored into <paramref name="range"/>.
 /// </summary>
 /// <param name="range">The <see cref="FilterCriteria.OptionalRange{T}"/> to store the parsed data into, if successful.</param>
 /// <param name="op">The operator for the keyword filter.</param>
 /// <param name="val">The value of the keyword filter.</param>
 /// <param name="parseFunction">Function used to determine if <paramref name="val"/> can be converted to type <typeparamref name="T"/>.</param>
 public static bool TryUpdateCriteriaRange <T>(ref FilterCriteria.OptionalRange <T> range, Operator op, string val, TryParseFunction <T> parseFunction)
     where T : struct
 => parseFunction.Invoke(val, out var converted) && tryUpdateCriteriaRange(ref range, op, converted);
Ejemplo n.º 7
0
 /// <summary>
 /// Attempts to parse a keyword filter of type <see cref="double"/>
 /// from the specified <paramref name="op"/> and <paramref name="val"/>.
 /// If <paramref name="val"/> can be parsed as a <see cref="double"/>, the function returns <c>true</c>
 /// and the resulting range constraint is stored into <paramref name="range"/>.
 /// </summary>
 /// <param name="range">
 /// The <see cref="double"/>-typed <see cref="FilterCriteria.OptionalRange{T}"/>
 /// to store the parsed data into, if successful.
 /// </param>
 /// <param name="op">The operator for the keyword filter.</param>
 /// <param name="val">The value of the keyword filter.</param>
 /// <param name="tolerance">Allowed tolerance of the parsed range boundary value.</param>
 public static bool TryUpdateCriteriaRange(ref FilterCriteria.OptionalRange <double> range, Operator op, string val, double tolerance = 0.05)
 => tryParseDoubleWithPoint(val, out double value) && tryUpdateCriteriaRange(ref range, op, value, tolerance);
Ejemplo n.º 8
0
 /// <summary>
 /// Attempts to parse a keyword filter of type <see cref="float"/>
 /// from the specified <paramref name="op"/> and <paramref name="val"/>.
 /// If <paramref name="val"/> can be parsed as a <see cref="float"/>, the function returns <c>true</c>
 /// and the resulting range constraint is stored into <paramref name="range"/>.
 /// </summary>
 /// <param name="range">
 /// The <see cref="float"/>-typed <see cref="FilterCriteria.OptionalRange{T}"/>
 /// to store the parsed data into, if successful.
 /// </param>
 /// <param name="op">The operator for the keyword filter.</param>
 /// <param name="val">The value of the keyword filter.</param>
 /// <param name="tolerance">Allowed tolerance of the parsed range boundary value.</param>
 public static bool TryUpdateCriteriaRange(ref FilterCriteria.OptionalRange <float> range, Operator op, string val, float tolerance = 0.05f)
 => tryParseFloatWithPoint(val, out float value) && tryUpdateCriteriaRange(ref range, op, value, tolerance);