예제 #1
0
        public override FilterNode <ClrValue> Visit(SingleValueFunctionCallNode nodeIn)
        {
            var fieldNode = nodeIn.Parameters.ElementAt(0);

            if (string.Equals(nodeIn.Name, "empty", StringComparison.OrdinalIgnoreCase))
            {
                return(ClrFilter.Empty(PropertyPathVisitor.Visit(fieldNode)));
            }

            if (string.Equals(nodeIn.Name, "empty", StringComparison.OrdinalIgnoreCase))
            {
                return(ClrFilter.Empty(PropertyPathVisitor.Visit(fieldNode)));
            }

            if (string.Equals(nodeIn.Name, "exists", StringComparison.OrdinalIgnoreCase))
            {
                return(ClrFilter.Exists(PropertyPathVisitor.Visit(fieldNode)));
            }

            var valueNode = nodeIn.Parameters.ElementAt(1);

            if (string.Equals(nodeIn.Name, "matchs", StringComparison.OrdinalIgnoreCase))
            {
                var value = ConstantWithTypeVisitor.Visit(valueNode);

                return(ClrFilter.Matchs(PropertyPathVisitor.Visit(fieldNode), value));
            }

            if (string.Equals(nodeIn.Name, "endswith", StringComparison.OrdinalIgnoreCase))
            {
                var value = ConstantWithTypeVisitor.Visit(valueNode);

                return(ClrFilter.EndsWith(PropertyPathVisitor.Visit(fieldNode), value));
            }

            if (string.Equals(nodeIn.Name, "startswith", StringComparison.OrdinalIgnoreCase))
            {
                var value = ConstantWithTypeVisitor.Visit(valueNode);

                return(ClrFilter.StartsWith(PropertyPathVisitor.Visit(fieldNode), value));
            }

            if (string.Equals(nodeIn.Name, "contains", StringComparison.OrdinalIgnoreCase))
            {
                var value = ConstantWithTypeVisitor.Visit(valueNode);

                return(ClrFilter.Contains(PropertyPathVisitor.Visit(fieldNode), value));
            }

            throw new NotSupportedException();
        }