Example #1
0
 public P?TryGetP(ExpressionSemantics semantics, object?value, IGremlinQueryEnvironment environment) => _overrideFactory.TryGetP(semantics, value, environment) ?? _originalFactory.TryGetP(semantics, value, environment);
Example #2
0
            public P?TryGetP(ExpressionSemantics semantics, object?value, IGremlinQueryEnvironment environment)
            {
                switch (semantics)
                {
                case ContainsExpressionSemantics:
                {
                    return(new P("eq", value));
                }

                case IntersectsExpressionSemantics:
                {
                    return(P.Within(value));
                }

                case IsContainedInExpressionSemantics:
                {
                    return(P.Within(value));
                }

                case StringExpressionSemantics stringExpressionSemantics when value is string stringValue:
                {
                    if (stringValue.Length == 0 || stringExpressionSemantics.Comparison == StringComparison.Ordinal || environment.Options.GetValue(GremlinqOption.StringComparisonTranslationStrictness) == StringComparisonTranslationStrictness.Lenient)
                    {
                        switch (stringExpressionSemantics)
                        {
                        case StringEqualsExpressionSemantics:
                        {
                            return(new P("eq", stringValue));
                        }

                        case IsPrefixOfExpressionSemantics:
                        {
                            return(P.Within(SubStrings(stringValue)));
                        }

                        case HasInfixExpressionSemantics:
                        {
                            return(stringValue.Length > 0
                                        ? TextP.Containing(stringValue)
                                        : PNeqNull);
                        }

                        case StartsWithExpressionSemantics:
                        {
                            return(stringValue.Length > 0
                                        ? TextP.StartingWith(stringValue)
                                        : PNeqNull);
                        }

                        case EndsWithExpressionSemantics:
                        {
                            return(stringValue.Length > 0
                                        ? TextP.EndingWith(stringValue)
                                        : PNeqNull);
                        }
                        }
                    }

                    break;
                }

                case EqualsExpressionSemantics:
                {
                    return(new P("eq", value));
                }

                case NotEqualsExpressionSemantics:
                {
                    return(new P("neq", value));
                }

                case ObjectExpressionSemantics:
                {
                    switch (semantics)
                    {
                    case LowerThanExpressionSemantics:
                    {
                        return(new P("lt", value));
                    }

                    case GreaterThanExpressionSemantics:
                    {
                        return(new P("gt", value));
                    }

                    case GreaterThanOrEqualExpressionSemantics:
                    {
                        return(new P("gte", value));
                    }

                    case LowerThanOrEqualExpressionSemantics:
                    {
                        return(new P("lte", value));
                    }
                    }

                    break;
                }
                }

                throw new ExpressionNotSupportedException();
            }