public ExprConcatNodeForgeEvalThreadLocal(
     ExprConcatNodeForge forge,
     ExprEvaluator[] evaluators)
 {
     _form = forge;
     _evaluators = evaluators;
 }
        public static CodegenExpression Codegen(
            ExprConcatNodeForge forge,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                typeof(string),
                typeof(ExprConcatNodeForgeEvalWNew),
                codegenClassScope);

            var block = methodNode.Block
                .DeclareVar<StringBuilder>("buf", NewInstance(typeof(StringBuilder)))
                .DeclareVarNoInit(typeof(string), "value");
            var chain = ExprDotMethodChain(Ref("buf"));
            foreach (ExprNode expr in forge.ForgeRenderable.ChildNodes) {
                block.AssignRef(
                        "value",
                        expr.Forge.EvaluateCodegen(typeof(string), methodNode, exprSymbol, codegenClassScope))
                    .IfRefNullReturnNull("value")
                    .ExprDotMethod(Ref("buf"), "Append", Ref("value"));
            }

            block.MethodReturn(ExprDotMethod(chain, "ToString"));
            return LocalMethod(methodNode);
        }
 internal ExprConcatNodeForgeEvalWNew(
     ExprConcatNodeForge forge,
     ExprEvaluator[] evaluators)
 {
     this._forge = forge;
     this._evaluators = evaluators;
 }
        protected internal static string Evaluate(
            EventBean[] eventsPerStream,
            bool isNewData,
            ExprEvaluatorContext context,
            StringBuilder buffer,
            ExprEvaluator[] evaluators,
            ExprConcatNodeForge form)
        {
            foreach (var child in evaluators) {
                var result = (string) child.Evaluate(eventsPerStream, isNewData, context);
                if (result == null) {
                    return null;
                }

                buffer.Append(result);
            }

            return buffer.ToString();
        }
Example #5
0
        public override ExprNode Validate(ExprValidationContext validationContext)
        {
            if (ChildNodes.Length < 2) {
                throw new ExprValidationException("Concat node must have at least 2 parameters");
            }

            for (var i = 0; i < ChildNodes.Length; i++) {
                var childType = ChildNodes[i].Forge.EvaluationType;
                var childTypeName = childType == null ? "null" : childType.CleanName();
                if (childType != typeof(string)) {
                    throw new ExprValidationException(
                        "Implicit conversion from datatype '" +
                        childTypeName +
                        "' to System.String is not allowed");
                }
            }

            ThreadingProfile threadingProfile = validationContext.StatementCompileTimeService.Configuration.Common
                .Execution.ThreadingProfile;
            _forge = new ExprConcatNodeForge(this, threadingProfile);
            return null;
        }