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