예제 #1
0
        public async Task TestTextP()
        {
            var expected            = TextP.Containing("o");
            var writer              = CreateGraphBinaryWriter();
            var reader              = CreateGraphBinaryReader();
            var serializationStream = new MemoryStream();

            await writer.WriteAsync(expected, serializationStream);

            serializationStream.Position = 0;
            var actual = (TextP)await reader.ReadAsync(serializationStream);

            Assert.Equal(expected.OperatorName, actual.OperatorName);
            Assert.Equal(expected.Other, actual.Other);
            Assert.Equal(expected.Value, actual.Value);
        }
예제 #2
0
        public Dictionary <string, dynamic> Dictify(dynamic predicate, IGraphSONWriter writer)
        {
            TextP p     = predicate;
            var   value = p.Other == null
                ? writer.ToDict(p.Value)
                : new List <dynamic>
            {
                writer.ToDict(p.Value), writer.ToDict(p.Other)
            };
            var dict = new Dictionary <string, dynamic>
            {
                { "predicate", p.OperatorName },
                { "value", value }
            };

            return(GraphSONUtil.ToTypedValue("TextP", dict));
        }
예제 #3
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();
            }
    bool canFollow = false; // Saber si hay un objetivo

    private void Awake()
    {
        //Se inicializa la cámara
        text           = FindObjectOfType <TextP>();
        sharedInstance = this;
    }