public void CodeEndsUpConcatinated() { var builder = new ExpressionBuilder(); builder.AppendExpression("x"); builder.AppendExpression("y"); builder.AppendExpression("z"); Assert.AreEqual("string.Concat(x,y,z)", builder.ToCode()); }
internal static AttributeNode AddMethodCallingToAttributeValue(AttributeNode node, string method) { var snippets = new Snippets {new Snippet {Value = method + "("}}; snippets.AddRange(node.AsCodeInverted()); snippets.Add(new Snippet {Value= ")"}); var builder = new ExpressionBuilder(); builder.AppendExpression(snippets); var listNodes=new List<Node> {new ExpressionNode(snippets)}; return new AttributeNode(node.Name, listNodes); }
public static Snippets AsCodeInverted(this AttributeNode attr) { var expression = new ExpressionBuilder(); foreach (var node in attr.Nodes) { if (node is TextNode) { expression.AppendLiteral(((TextNode)node).Text); } else if (node is ExpressionNode) { expression.AppendExpression(((ExpressionNode)node).Code); } else if (node is EntityNode) { expression.AppendLiteral("&" + ((EntityNode)node).Name + ";"); } } return new Snippets(expression.ToCode()); }