Ejemplo n.º 1
0
        /// <inheritdoc />
        public override Expression <Func <Event, bool> > GetFilterExpression()
        {
            if (_specifications.Length == 0)
            {
                return(e => true);
            }

            Expression <Func <Event, bool> > result = _specifications[0].GetFilterExpression();

            var parameterReplacer = new ParameterReplacer();

            foreach (var specification in _specifications.Skip(1))
            {
                var filterExpression = specification.GetFilterExpression();

                var parameter = Expression.Parameter(typeof(Event));

                result = Expression.Lambda <Func <Event, bool> >(
                    Expression.OrElse(
                        parameterReplacer.ReplaceParameterWith(parameter, result.Body),
                        parameterReplacer.ReplaceParameterWith(parameter, filterExpression.Body)
                        ),
                    parameter);
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public override Expression <Func <Event, bool> > GetFilterExpression()
        {
            var parameterReplacer = new ParameterReplacer();

            var filterExpression = _specification.GetFilterExpression();

            var parameter = Expression.Parameter(typeof(Event));

            var result = Expression.Lambda <Func <Event, bool> >(
                Expression.Not(
                    parameterReplacer.ReplaceParameterWith(parameter, filterExpression.Body)
                    ),
                parameter);

            return(result);
        }