Пример #1
0
        public Object Evaluate(
            Object target,
            EventBean[] eventsPerStream,
            bool isNewData,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            if (target is EventBean)
            {
                target = Collections.SingletonList((EventBean)target);
            }

            var enumerationMethodCache = exprEvaluatorContext.ExpressionResultCacheService.AllocateEnumerationMethod;

            if (_cache)
            {
                var cacheValue = enumerationMethodCache.GetEnumerationMethodLastValue(this);
                if (cacheValue != null)
                {
                    return(cacheValue.Result);
                }
                var coll = target.Unwrap <object>();
                if (coll == null)
                {
                    return(null);
                }
                var eventsLambda = AllocateCopyEventLambda(eventsPerStream);
                var result       = _enumEval.EvaluateEnumMethod(eventsLambda, coll, isNewData, exprEvaluatorContext);
                enumerationMethodCache.SaveEnumerationMethodLastValue(this, result);
                return(result);
            }

            _contextNumber++;
            try
            {
                enumerationMethodCache.PushContext(_contextNumber);
                var coll = target.Unwrap <object>();
                if (coll == null)
                {
                    return(null);
                }
                var eventsLambda = AllocateCopyEventLambda(eventsPerStream);
                return(_enumEval.EvaluateEnumMethod(eventsLambda, coll, isNewData, exprEvaluatorContext));
            }
            finally
            {
                enumerationMethodCache.PopContext();
            }
        }
Пример #2
0
        public object Evaluate(
            object target,
            EventBean[] eventsPerStream,
            bool isNewData,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            if (target is EventBean eventBean) {
                target = Collections.SingletonList(eventBean);
            }

            var coll = target.Unwrap<object>();
            if (coll == null) {
                return null;
            }

            var eventsLambda = eventsPerStream == null ? new EventBean[0] : AllocateCopyEventLambda(eventsPerStream, enumEvalNumRequiredEvents);
            return enumEval.EvaluateEnumMethod(eventsLambda, coll, isNewData, exprEvaluatorContext);
        }