public Indent ( System.Action Action ) : void | ||
Action | System.Action | |
return | void |
public void TestIndentation() { var Output = new IndentedStringBuilder(); Output.Write("{\n"); Output.Indent(() => { Output.Write("Hello World!\n"); Output.Write("Goodbye World!\n"); }); Output.Write("}\n"); Assert.AreEqual( @"{\n" + @" Hello World!\n" + @" Goodbye World!\n" + @"}\n", AstStringUtils.ToLiteralRaw(Output.ToString()) ); }
private static void SerializeAsXml(AstNode Node, IndentedStringBuilder Out, bool Spaces) { var NodeName = Node.GetType().Name; Out.Write("<" + NodeName); var Parameters = Node.Info; if (Parameters != null) { foreach (var Pair in Parameters) { Out.Write(String.Format(" {0}=\"{1}\"", Pair.Key, Pair.Value)); } } if (Node.Childs.Count() > 0) { Out.Write(">"); if (Spaces) Out.WriteNewLine(); if (Spaces) { Out.Indent(() => { foreach (var Child in Node.Childs) SerializeAsXml(Child, Out, Spaces); }); } else { foreach (var Child in Node.Childs) SerializeAsXml(Child, Out, Spaces); } Out.Write("</" + NodeName + ">"); if (Spaces) Out.WriteNewLine(); } else { Out.Write(" />"); if (Spaces) Out.WriteNewLine(); } }