Spark.Search.Criterium.buildValue C# (CSharp) Méthode

buildValue() private méthode

private buildValue ( ) : string
Résultat string
        private string buildValue()
        {
            // Turn ISNULL and NOTNULL operators into either true/or false to match the :missing modifier
            if (Type == Operator.ISNULL) return "true";
            if (Type == Operator.NOTNULL) return "false";

            if(Operand == null) throw new InvalidOperationException("Criterium does not have an operand");
            if(!(Operand is ValueExpression)) throw new FormatException("Expected a ValueExpression as operand");

            string value = Operand.ToString();

            // Add comparator if we have one
            switch (Type)
            {
                case Operator.APPROX: return "~" + value;
                case Operator.EQ: return value;
                case Operator.IN: return value;
                case Operator.GT: return ">" + value;
                case Operator.GTE: return ">=" + value;
                case Operator.LT: return "<" + value;
                case Operator.LTE: return "<=" + value;
                default:
                    throw Error.NotImplemented("Operator of type '{0}' is not supported", Type.ToString());
            }
        }