Esempio n. 1
0
        public ArrayNode(string elementType, IValueNode[] array)
        {
            if (array == null)
                throw new ArgumentNullException(nameof(array));

            this.elementType = elementType;
            this.array = array;
        }
Esempio n. 2
0
        public PropertyNode(string property, IValueNode value)
        {
            if (property == null)
                throw new ArgumentNullException(nameof(property));
            if (value == null)
                throw new ArgumentNullException(nameof(value));

            this.property = property;
            this.value = value;
        }
Esempio n. 3
0
 public static IError ProjectionProvider_CouldNotProjectSorting(
     IValueNode node) =>
 ErrorBuilder.New()
 .SetMessage(DataResources.ProjectionProvider_CouldNotProjectSorting)
 .AddLocation(node)
 .Build();
Esempio n. 4
0
 /// <summary>
 /// Defines if the specified <paramref name="literal" />
 /// can be parsed by this scalar.
 /// </summary>
 /// <param name="literal">
 /// The literal that shall be checked.
 /// </param>
 /// <returns>
 /// <c>true</c> if the literal can be parsed by this scalar;
 /// otherwise, <c>false</c>.
 /// </returns>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="literal" /> is <c>null</c>.
 /// </exception>
 public abstract bool IsInstanceOfType(IValueNode literal);
Esempio n. 5
0
 public ArgumentNode WithValue(IValueNode value)
 {
     return(new ArgumentNode(Location, Name, value));
 }
Esempio n. 6
0
 public ArgumentNode(NameNode name, IValueNode value)
     : this(null, name, value)
 {
 }
Esempio n. 7
0
 public abstract bool IsInstanceOfType(IValueNode valueSyntax);
Esempio n. 8
0
 public override bool IsInstanceOfType(IValueNode valueSyntax)
 {
     throw new NotImplementedException();
 }
 public VariableDefinitionNode WithDefaultValue(IValueNode defaultValue)
 {
     return(new VariableDefinitionNode(
                Location, Variable, Type,
                defaultValue));
 }
        public void Create_ArraySomeObjectEqual_Multiple()
        {
            // arrange
            IValueNode value = Utf8GraphQLParser.Syntax.ParseValueLiteral(
                "{ fooNested: {some: {bar: { eq: \"a\" }}} otherProperty: {eq:null}}");
            ExecutorBuilder tester = CreateProviderTester(new FooFilterInput());

            // act
            Func <Foo, bool>?func = tester.Build <Foo>(value);

            // assert
            var a = new Foo
            {
                FooNested = new[]
                {
                    new FooNested {
                        Bar = "a"
                    },
                    new FooNested {
                        Bar = "a"
                    },
                    new FooNested {
                        Bar = "a"
                    }
                }
            };

            Assert.True(func(a));

            var b = new Foo
            {
                FooNested = new[]
                {
                    new FooNested {
                        Bar = "c"
                    },
                    new FooNested {
                        Bar = "a"
                    },
                    new FooNested {
                        Bar = "a"
                    }
                }
            };

            Assert.True(func(b));

            var c = new Foo
            {
                FooNested = new[]
                {
                    new FooNested {
                        Bar = "a"
                    },
                    new FooNested {
                        Bar = "d"
                    },
                    new FooNested {
                        Bar = "b"
                    }
                }
            };

            Assert.True(func(c));

            var d = new Foo
            {
                FooNested = new[]
                {
                    new FooNested {
                        Bar = "c"
                    },
                    new FooNested {
                        Bar = "d"
                    },
                    new FooNested {
                        Bar = "b"
                    }
                }
            };

            Assert.False(func(d));

            var e = new Foo
            {
                FooNested = new[]
                {
                    null,
                    new FooNested {
                        Bar = null
                    },
                    new FooNested {
                        Bar = "d"
                    },
                    new FooNested {
                        Bar = "b"
                    }
                }
            };

            Assert.False(func(e));

            var f = new Foo
            {
                OtherProperty = "ShouldBeNull",
                FooNested     = new[]
                {
                    new FooNested {
                        Bar = "c"
                    },
                    new FooNested {
                        Bar = "a"
                    },
                    new FooNested {
                        Bar = "a"
                    }
                }
            };

            Assert.False(func(f));
        }
        public void Create_ArrayAllObjectStringEqual_Expression()
        {
            // arrange
            IValueNode value = Utf8GraphQLParser.Syntax.ParseValueLiteral(
                "{ fooNested: {all: { bar: {eq: \"a\" }}}}");
            ExecutorBuilder?tester = CreateProviderTester(new FooFilterInput());

            // act
            Func <Foo, bool>?func = tester.Build <Foo>(value);

            // assert
            var a = new Foo
            {
                FooNested = new[]
                {
                    new FooNested {
                        Bar = "a"
                    },
                    new FooNested {
                        Bar = "a"
                    },
                    new FooNested {
                        Bar = "a"
                    }
                }
            };

            Assert.True(func(a));

            var b = new Foo
            {
                FooNested = new[]
                {
                    new FooNested {
                        Bar = "c"
                    },
                    new FooNested {
                        Bar = "a"
                    },
                    new FooNested {
                        Bar = "a"
                    }
                }
            };

            Assert.False(func(b));

            var c = new Foo
            {
                FooNested = new[]
                {
                    new FooNested {
                        Bar = "a"
                    },
                    new FooNested {
                        Bar = "d"
                    },
                    new FooNested {
                        Bar = "b"
                    }
                }
            };

            Assert.False(func(c));

            var d = new Foo
            {
                FooNested = new[]
                {
                    new FooNested {
                        Bar = "c"
                    },
                    new FooNested {
                        Bar = "d"
                    },
                    new FooNested {
                        Bar = "b"
                    }
                }
            };

            Assert.False(func(d));

            var e = new Foo
            {
                FooNested = new[]
                {
                    null,
                    new FooNested {
                        Bar = null
                    },
                    new FooNested {
                        Bar = "d"
                    },
                    new FooNested {
                        Bar = "b"
                    }
                }
            };

            Assert.False(func(e));
        }
Esempio n. 12
0
 IArgumentDescriptor IArgumentDescriptor.DefaultValue(IValueNode valueNode)
 {
     DefaultValue       = valueNode ?? new NullValueNode();
     NativeDefaultValue = null;
     return(this);
 }
Esempio n. 13
0
 public IndexedValueNode(IValueNode <TPrev> prevNode, int index, T value) =>
 (PrevNode, Index, Value) = (prevNode, index, value);
Esempio n. 14
0
 public override object?ParseLiteral(IValueNode valueSyntax, bool withDefaults = true)
 {
     throw new NotImplementedException();
 }
 protected override void OnInitNewState(Context context)
 {
     base.OnInitNewState(context);
     m_value = (IValueNode) m_sequence;
     m_value.InitNewState(context);
 }
Esempio n. 16
0
 public CollectionNode(string collectionType, string elementType, IValueNode[] array)
     : base(elementType, array)
 {
     this.collectionType = collectionType;
 }
Esempio n. 17
0
 public static IValueNode Rewrite(
     IValueNode value,
     IType type,
     IVariableValueCollection variables,
     ITypeConversion typeConversion) =>
 _current.Value.RewriteValue(value, type, variables, typeConversion);
Esempio n. 18
0
 public void Visit(IValueNode valueNode)
 {
     ((FilterDescriptor)CurrentDescriptor).Value = valueNode.Value;
 }
Esempio n. 19
0
 /// <inheritdoc />
 protected override SerializationException CreateParseLiteralError(IValueNode valueSyntax)
 {
     return(ThrowHelper.IsbnType_ParseLiteral_IsInvalid(this));
 }
Esempio n. 20
0
 public abstract object?ParseLiteral(IValueNode valueSyntax, bool withDefaults = true);
 /// <summary>
 /// Maps a operation field to a provider specific result.
 /// This method is called when the <see cref="FilterVisitor{TContext,T}"/> enters a
 /// field
 /// </summary>
 /// <param name="context">The <see cref="IFilterVisitorContext{T}"/> of the visitor</param>
 /// <param name="field">The field that is currently being visited</param>
 /// <param name="value">The value node of this field</param>
 /// <param name="parsedValue">The value of the value node</param>
 /// <returns>If <c>true</c> is returned the action is used for further processing</returns>
 public abstract MongoDbFilterDefinition HandleOperation(
     MongoDbFilterVisitorContext context,
     IFilterOperationField field,
     IValueNode value,
     object?parsedValue);
Esempio n. 22
0
 public ArgumentNode(string name, IValueNode value)
     : this(null, new NameNode(name), value)
 {
 }
Esempio n. 23
0
 IInputFieldDescriptor IInputFieldDescriptor.DefaultValue(
     IValueNode defaultValue)
 {
     DefaultValue(defaultValue);
     return(this);
 }
Esempio n. 24
0
 public ArgumentNode(Location?location, NameNode name, IValueNode value)
 {
     Location = location;
     Name     = name ?? throw new ArgumentNullException(nameof(name));
     Value    = value ?? throw new ArgumentNullException(nameof(value));
 }
Esempio n. 25
0
 /// <inheritdoc />
 protected override SerializationException CreateParseLiteralError(IValueNode valueSyntax)
 {
     throw ThrowHelper.NegativeIntType_ParseLiteral_IsNotNegative(this);
 }
Esempio n. 26
0
 /// <summary>
 /// Parses the specified <paramref name="literal" />
 /// to the .net representation of this type.
 /// </summary>
 /// <param name="literal">
 /// The literal that shall be parsed.
 /// </param>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="literal" /> is <c>null</c>.
 /// </exception>
 /// <exception cref="ScalarSerializationException">
 /// The specified <paramref name="literal" /> cannot be parsed
 /// by this scalar.
 /// </exception>
 public abstract object ParseLiteral(IValueNode literal);
 public abstract Expression HandleOperation(
     QueryableFilterContext context,
     IFilterOperationField field,
     IValueNode value,
     object parsedValue);
Esempio n. 28
0
 public static GraphQLException FieldVisibility_ValueNotSupported(IValueNode value) =>
 new GraphQLException(
     ErrorBuilder.New()
     .SetMessage(ThrowHelper_FieldVisibility_ValueNotSupported_Message)
     .AddLocation(value)
     .Build());
Esempio n. 29
0
 internal T DeserializeArgument <T>(
     Argument argument,
     IValueNode valueNode)
 {
     return((T)DeserializeArgument(argument, valueNode, typeof(T)));
 }
Esempio n. 30
0
 public new IArgumentDescriptor DefaultValue(IValueNode value)
 {
     base.DefaultValue(value);
     return(this);
 }
 IDirectiveArgumentDescriptor IDirectiveArgumentDescriptor.DefaultValue(
     IValueNode defaultValue)
 {
     DefaultValue(defaultValue);
     return(this);
 }
Esempio n. 32
0
 private string CreateValue(IValueNode value)
 {
     if (value is ReferenceNode)
         return CreateReference((ReferenceNode)value);
     if (value is NumberNode)
         return CreateNumber((NumberNode)value);
     if (value is StringNode)
         return CreateString((StringNode)value);
     if (value is EnumNode)
         return CreateEnum((EnumNode)value);
     if (value is BindingNode)
         return CreateBinding((BindingNode)value);
     if (value is CollectionNode)
         return CreateCollection((CollectionNode)value);
     if (value is ArrayNode)
         return CreateArray((ArrayNode)value);
     else
         // todo: ...!
         throw new Exception();
 }
        protected override void Deserialize(StringReader reader)
        {
            base.Deserialize(reader);

            Value = PExpressionUtility.DeserializeValue(reader);
        }
 public static void SerializeValue(IValueNode value, StringWriter writer)
 {
     if (value == null || value.Value == null)
         writer.WriteLine();
     else
     {
         writer.WriteLine(value.Type.FullName);
         writer.WriteLine(Convert.ToString(value.Value));
     }
 }
 public override bool IsInstanceOfType(IValueNode literal)
 {
     throw new NotImplementedException();
 }
 protected override void LoadDataFromXml(XmlElement element, Context context)
 {
     base.LoadDataFromXml(element, context);
     ChildValue = (IValueNode) SequenceFactory.Instance.CreateChildrenAsSequence(element, context);
 }
 public override object ParseLiteral(IValueNode literal)
 {
     throw new NotImplementedException();
 }
 protected virtual ISyntaxVisitorAction Enter(
     IValueNode node,
     ISyntaxVisitorContext context) =>
 DefaultAction;
Esempio n. 39
0
        public override Expression HandleOperation(QueryableFilterContext context, IFilterOperationField field, IValueNode value, object?parsedValue)
        {
            Expression property = context.GetInstance();

            if (parsedValue is string fieldValue)
            {
                //Compiles to:
                //property.ToLower().Contains(input.ToLower());

                return(Expression.Call(Expression.Call(property, Expressions.ToLower), Expressions.Contains, Expression.Constant(fieldValue.ToLower())));
            }

            throw new InvalidOperationException();
        }