Beispiel #1
0
        public static IAggregateExpression CompileAggregateExpression(NamedExpressionElement element, IEnumerable <Declaration> declarations)
        {
            var declarationsList = declarations.ToList();

            if (element.Imports.Count() == 1 &&
                Equals(element.Imports.Single(), declarationsList.Last()))
            {
                var optimizer           = new ExpressionSingleParameterOptimizer <Func <object, object> >();
                var optimizedExpression = optimizer.ConvertParameter(element.Expression);
                var @delegate           = optimizedExpression.Compile();
                var fastDelegate        = Create(@delegate, element.Expression.Parameters.Count);
                var expression          = new AggregateFactExpression(element.Name, element.Expression, fastDelegate);
                return(expression);
            }
            else
            {
                var optimizer           = new ExpressionMultiParameterOptimizer <Func <object[], object> >();
                var optimizedExpression = optimizer.CompactParameters(element.Expression, 0);
                var @delegate           = optimizedExpression.Compile();
                var fastDelegate        = Create(@delegate, element.Expression.Parameters.Count);
                var factMap             = IndexMap.CreateMap(element.Imports, declarationsList);
                var expression          = new AggregateExpression(element.Name, element.Expression, fastDelegate, factMap);
                return(expression);
            }
        }
Beispiel #2
0
        public static FastDelegate <Func <object, bool> > AlphaCondition(LambdaExpression expression)
        {
            var optimizer           = new ExpressionSingleParameterOptimizer <Func <object, bool> >();
            var optimizedExpression = optimizer.ConvertParameter(expression);
            var @delegate           = optimizedExpression.Compile();
            var fastDelegate        = Create(@delegate, expression.Parameters.Count);

            return(fastDelegate);
        }
Beispiel #3
0
        public static IAlphaCondition CompileAlphaCondition(ConditionElement element)
        {
            var optimizer           = new ExpressionSingleParameterOptimizer <Func <object, bool> >();
            var optimizedExpression = optimizer.ConvertParameter(element.Expression);
            var @delegate           = optimizedExpression.Compile();
            var fastDelegate        = Create(@delegate, element.Expression.Parameters.Count);
            var condition           = new AlphaCondition(element.Expression, fastDelegate);

            return(condition);
        }