Example #1
0
 public static string ToString(LuaTable table, LuaComment headComment = null)
 {
     using (var stringWriter = new StringWriter()) {
         Write(table, stringWriter, headComment);
         return(stringWriter.ToString());
     }
 }
Example #2
0
 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();
     }
 }
Example #3
0
        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);
            }
        }
Example #4
0
 public static void Write(LuaTable table, FileInfo fileInfo, LuaComment headComment = null)
 {
     using (var file = fileInfo.CreateText()) {
         Write(table, file, headComment);
     }
 }