public static IEnumerable <BinaryExpression> Collect(Expression expression)
        {
            var collector = new ExpressionCollector();

            collector.Traverse(expression);

            return(collector._expressions);
        }
Пример #2
0
        private string GetMessage()
        {
            ExpressionWrapper <T>[] wrappers = ExpressionCollector
                                               .Collect(_predicate.Body)
                                               .Select(e => new ExpressionWrapper <T>(_predicate.Parameters, e))
                                               .ToArray();

            IEnumerable <ObjectWrapper <T> > objectWrappers = _sources.Select(s => new ObjectWrapper <T>(s, wrappers));
            ObjectWrapper <T> bestMatch = objectWrappers.OrderByDescending(o => o.MatchCount).First();

            return(bestMatch.GetMessage());
        }