コード例 #1
0
 /// <summary>
 ///     Binary condition for String equality comparison using Json Path.
 /// </summary>
 /// <param name="variable">
 ///     The JSONPath expression that determines which piece of the input document is used for the
 ///     comparison
 /// </param>
 /// <param name="expectedValuePath">The JSONPath expression that determines the expected value for this condition</param>
 /// <returns>
 ///     <see cref="StringEqualsPathCondition.Builder" />
 /// </returns>
 public static StringEqualsPathCondition.Builder StringEqualsPath(string variable, string expectedValuePath)
 {
     return(StringEqualsPathCondition.GetBuilder().Variable(variable).ExpectedValuePath(expectedValuePath));
 }
コード例 #2
0
        public IConditionBuilder<ICondition> DeserializeCondition(JObject node)
        {
            if (node.Property(PropertyNames.VARIABLE) != null)
            {
                if (node.Property(PropertyNames.STRING_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(StringEqualsCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.STRING_EQUALS_PATH) != null)
                {
                    return DeserializeBinaryPathCondition(StringEqualsPathCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.STRING_GREATER_THAN) != null)
                {
                    return DeserializeBinaryCondition(StringGreaterThanCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.STRING_GREATER_THAN_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(StringGreaterThanOrEqualCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.STRING_LESS_THAN) != null)
                {
                    return DeserializeBinaryCondition(StringLessThanCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.STRING_LESS_THAN_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(StringLessThanOrEqualCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.TIMESTAMP_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(TimestampEqualCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.TIMESTAMP_GREATER_THAN) != null)
                {
                    return DeserializeBinaryCondition(TimestampGreaterThanCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.TIMESTAMP_GREATER_THAN_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(TimestampGreaterThanOrEqualCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.TIMESTAMP_LESS_THAN) != null)
                {
                    return DeserializeBinaryCondition(TimestampLessThanCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.TIMESTAMP_LESS_THAN_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(TimestampLessThanOrEqualCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.NUMERIC_EQUALS) != null)
                {
                    if (node.Property(PropertyNames.NUMERIC_EQUALS).Value.Type == JTokenType.Integer)
                    {
                        return DeserializeBinaryCondition(NumericEqualsCondition<long>.GetBuilder(), node);
                    }

                    return DeserializeBinaryCondition(NumericEqualsCondition<decimal>.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.NUMERIC_GREATER_THAN) != null)
                {
                    if (node.Property(PropertyNames.NUMERIC_GREATER_THAN).Value.Type == JTokenType.Integer)
                    {
                        return DeserializeBinaryCondition(NumericGreaterThanCondition<long>.GetBuilder(), node);
                    }

                    return DeserializeBinaryCondition(NumericGreaterThanCondition<decimal>.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.NUMERIC_GREATER_THAN_EQUALS) != null)
                {
                    if (node.Property(PropertyNames.NUMERIC_GREATER_THAN_EQUALS).Value.Type == JTokenType.Integer)
                    {
                        return DeserializeBinaryCondition(NumericGreaterThanOrEqualCondition<long>.GetBuilder(), node);
                    }

                    return DeserializeBinaryCondition(NumericGreaterThanOrEqualCondition<decimal>.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.NUMERIC_LESS_THAN) != null)
                {
                    if (node.Property(PropertyNames.NUMERIC_LESS_THAN).Value.Type == JTokenType.Integer)
                    {
                        return DeserializeBinaryCondition(NumericLessThanCondition<long>.GetBuilder(), node);
                    }

                    return DeserializeBinaryCondition(NumericLessThanCondition<decimal>.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.NUMERIC_LESS_THAN_EQUALS) != null)
                {
                    if (node.Property(PropertyNames.NUMERIC_LESS_THAN_EQUALS).Value.Type == JTokenType.Integer)
                    {
                        return DeserializeBinaryCondition(NumericLessThanOrEqualCondition<long>.GetBuilder(), node);
                    }

                    return DeserializeBinaryCondition(NumericLessThanOrEqualCondition<decimal>.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.BOOLEAN_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(BooleanEqualsCondition.GetBuilder(), node);
                }
            }
            else if (node.Property(PropertyNames.AND) != null)
            {
                var builder = AndCondition.GetBuilder();
                foreach (var inner in node[PropertyNames.AND].Children())
                {
                    builder.Condition(DeserializeCondition((JObject) inner));
                }

                return builder;
            }
            else if (node.Property(PropertyNames.OR) != null)
            {
                var builder = OrCondition.GetBuilder();
                foreach (var inner in node[PropertyNames.OR].Children())
                {
                    builder.Condition(DeserializeCondition((JObject) inner));
                }

                return builder;
            }
            else if (node.Property(PropertyNames.NOT) != null)
            {
                return NotCondition.GetBuilder()
                    .Condition(DeserializeCondition((JObject) node.Property(PropertyNames.NOT).First));
            }

            throw new StatesLanguageException("Condition must be provided");
        }