Пример #1
0
 public void AddSeveralLiterals()
 {
     var builder = new ExpressionBuilder();
     builder.AppendLiteral("hello");
     builder.AppendLiteral("world");
     Assert.AreEqual("\"helloworld\"", builder.ToCode());
 }
Пример #2
0
 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());
 }
Пример #3
0
 public void TextIsEscaped()
 {
     var builder = new ExpressionBuilder();
     builder.AppendLiteral("\"\\\t");
     Assert.AreEqual("\"\\\"\\\\\\t\"", builder.ToCode());
 }