public static string ToString(LuaTable table, LuaComment headComment = null) { using (var stringWriter = new StringWriter()) { Write(table, stringWriter, headComment); return(stringWriter.ToString()); } }
private static void Write(LuaComment comment, IndentedTextWriter indentedTextWriter) { if (comment.BlankLineBefore) { indentedTextWriter.WriteLine(); } foreach (var line in comment.Text.SplitIntoLines()) { indentedTextWriter.WriteLine("-- {0}", line); } if (comment.BlankLineAfter) { indentedTextWriter.WriteLine(); } }
public static void Write(LuaTable table, TextWriter textWriter, LuaComment headComment = null) { if (table == null) { throw new ArgumentNullException("table"); } if (textWriter == null) { throw new ArgumentNullException("textWriter"); } using (var indentedTextWriter = new IndentedTextWriter(textWriter, " ")) { if (headComment != null) { Write(headComment, indentedTextWriter); } indentedTextWriter.Write("return "); Write(table, indentedTextWriter); } }
public static void Write(LuaTable table, FileInfo fileInfo, LuaComment headComment = null) { using (var file = fileInfo.CreateText()) { Write(table, file, headComment); } }