public IPredicateVisitor Convert(Expression expression, IPredicateVisitorFactory predicateVisitorFactory)
        {
            MethodCallExpression methodCallExpression = expression as MethodCallExpression;

            if (methodCallExpression == null)
            {
                return(null);
            }

            string methodName = FilterMapping.AllowedGroupMethods[methodCallExpression.Method.Name];
            ConstantPredicateVisitor method     = new ConstantPredicateVisitor(methodName);
            IPredicateVisitor        parent     = predicateVisitorFactory.Create(methodCallExpression.Arguments[0]);
            List <IPredicateVisitor> parameters = new List <IPredicateVisitor>();

            if (methodCallExpression.Arguments[1].NodeType != ExpressionType.NewArrayInit)
            {
                return(null);
            }

            foreach (Expression part in ((NewArrayExpression)methodCallExpression.Arguments[1]).Expressions)
            {
                parameters.Add(predicateVisitorFactory.Create(part));
            }

            CollectionPredicateVisitor collection = new CollectionPredicateVisitor(parameters);
            EqualPredicateVisitor      equal      = new EqualPredicateVisitor(method, collection);

            Visitors.AccessorPredicateVisitor accessor = new Visitors.AccessorPredicateVisitor(equal, parent);
            return(accessor);
        }
        private static bool ArePropertiesEqual(Visitors.AccessorPredicateVisitor left, Visitors.AccessorPredicateVisitor right)
        {
            ConstantPredicateVisitor constantLeft  = left.Current as ConstantPredicateVisitor;
            ConstantPredicateVisitor constantRight = right.Current as ConstantPredicateVisitor;

            if (constantLeft != null && constantRight != null)
            {
                return(constantLeft.Constant == constantRight.Constant);
            }

            return(false);
        }
        private static IPredicateVisitor CombinePredicateVisitors(IPredicateVisitor left, IPredicateVisitor right)
        {
            EqualPredicateVisitor equalLeft  = left as EqualPredicateVisitor;
            EqualPredicateVisitor equalRight = right as EqualPredicateVisitor;

            Visitors.AccessorPredicateVisitor accessorLeft  = equalLeft?.Left as Visitors.AccessorPredicateVisitor;
            Visitors.AccessorPredicateVisitor accessorRight = equalRight?.Left as Visitors.AccessorPredicateVisitor;
            IPredicateVisitor collection;

            if (equalLeft?.Right is RangeCollectionPredicateVisitor rangeLeft &&
                equalRight?.Right is RangeCollectionPredicateVisitor rangeRight)
            {
                List <RangePredicateVisitor> combinedRanges = new List <RangePredicateVisitor>();
                combinedRanges.AddRange(rangeLeft.Ranges);
                combinedRanges.AddRange(rangeRight.Ranges);
                collection = new RangeCollectionPredicateVisitor(combinedRanges);
            }