/// <inheritdoc />
        public void Visit(MorestachioMultiPartExpressionList expression)
        {
            StringBuilder
            .AppendLine("Exp[")
            .Up()
            .AppendInterlaced();
            for (var index = 0; index < expression.Expressions.Count; index++)
            {
                var expressionExpression = expression.Expressions[index];
                this.Visit(expressionExpression);
                if (index != expression.Expressions.Count - 1)
                {
                    StringBuilder.AppendLine(",").AppendInterlaced();
                }
            }

            StringBuilder.Down()
            .AppendLine()
            .AppendInterlaced("]");

            if (expression.EndsWithDelimiter)
            {
                StringBuilder.Append("Eoex");
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public void Visit(MorestachioMultiPartExpressionList expression)
        {
            for (var index = 0; index < expression.Expressions.Count; index++)
            {
                var expressionExpression = expression.Expressions[index];

                if (index != 0 &&
                    !(expressionExpression is MorestachioExpression exp &&
                      (exp.PathParts.Current.Value == PathType.SelfAssignment
                       ||
                       (exp.PathParts.Current.Value == PathType.DataPath && exp.PathParts.Current.Key is null))))
                {
                    StringBuilder.Append(".");
                }
                this.Visit(expressionExpression);
            }
        }
Exemplo n.º 3
0
        internal static IMorestachioExpression ParseExpressionFromKind(this XmlReader reader)
        {
            IMorestachioExpression exp = null;

            switch (reader.Name)
            {
            case "Expression":
                exp = new MorestachioExpression();
                break;

            case "ExpressionMultiPart":
                exp = new MorestachioMultiPartExpressionList();
                break;

            case "ExpressionArgList":
                exp = new MorestachioArgumentExpressionList();
                break;

            case "ExpressionString":
                exp = new MorestachioExpressionString();
                break;

            case "ExpressionNumber":
                exp = new MorestachioExpressionNumber();
                break;

            case "ExpressionOperator":
                exp = new MorestachioOperatorExpression();
                break;

            case "ExpressionBracket":
                exp = new MorestachioBracketExpression();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(ExpressionKindNodeName));
            }
            exp.ReadXml(reader);
            return(exp);
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        public void Visit(MorestachioMultiPartExpressionList expression)
        {
            for (var index = 0; index < expression.Expressions.Count; index++)
            {
                var expressionExpression = expression.Expressions[index];
                if (index > 0)
                {
                    if (expressionExpression is MorestachioExpression exp)
                    {
                        var c = exp.PathParts.Current.Value;
                        if (c != PathType.SelfAssignment)
                        {
                            StringBuilder.Append(".");
                        }
                    }
                    else
                    {
                        StringBuilder.Append(".");
                    }
                }

                //if (index != 0
                //	&& (expressionExpression is MorestachioExpression exp
                //		 && (exp.PathParts.Current.Value != PathType.SelfAssignment
                //		     ||
                //		     (exp.PathParts.Current.Value == PathType.DataPath && exp.PathParts.Current.Key is null))))
                //{
                //	StringBuilder.Append(".");
                //}
                this.Visit(expressionExpression);
            }

            if (expression.EndsWithDelimiter && !TrimEoexDelimiters)
            {
                StringBuilder.Append(";");
            }
        }