public void AddSeveralLiterals() { var builder = new ExpressionBuilder(); builder.AppendLiteral("hello"); builder.AppendLiteral("world"); Assert.AreEqual("\"helloworld\"", builder.ToCode()); }
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()); }
public void TextIsEscaped() { var builder = new ExpressionBuilder(); builder.AppendLiteral("\"\\\t"); Assert.AreEqual("\"\\\"\\\\\\t\"", builder.ToCode()); }