/// <summary> /// Export the categories to a new string builder instance. /// </summary> /// <param name="categories"></param> /// <returns></returns> public static StringBuilder ExportCompressedLuaCategories(IDictionary <string, List <object> > categories) { // Export all of the Categories var builder = new StringBuilder(); builder.AppendLine("_.Categories={};"); builder.Append("local l={};"); int categoryCount = 0; foreach (var pair in categories) { if (categoryCount++ > 0) { builder.Append("l={};"); } builder.Append("_.Categories.").Append(pair.Key).AppendLine("=l;"); foreach (var group in pair.Value) { builder.Append("tinsert(l,"); ExportCompressedLua(builder, group); builder.AppendLine(");"); } } // Simplify the structure of the string and then export to the builder. SimplifyStructureForLua(builder); ExportShortcutsForLua(builder); ExportCategoriesHeaderForLua(builder); STRUCTURE_COUNTS.Clear(); FUNCTION_SHORTCUTS.Clear(); return(builder); }
/// <summary> /// Export the contents of the dictionary to the builder in a raw, longhand format. /// Every field will be written. Standardized formatting applies here. /// </summary> /// <typeparam name="KEY">The key value type of the dictionary.</typeparam> /// <typeparam name="VALUE">The value type of the dictionary.</typeparam> /// <param name="data">The data dictionary.</param> /// <returns>A built string containing the information.</returns> public static StringBuilder ExportCompressedLua <KEY, VALUE>(Dictionary <KEY, VALUE> data) { var builder = new StringBuilder(); ExportCompressedLua(builder, data); STRUCTURE_COUNTS.Clear(); FUNCTION_SHORTCUTS.Clear(); return(builder); }
/// <summary> /// Export the contents of the list to the builder in a raw, longhand format. /// Every element will be written. Standardized formatting applies here. /// </summary> /// <param name="list">The list of data.</param> /// <returns>A built string containing the information.</returns> public static StringBuilder ExportCompressedLua <T>(List <T> list) { var builder = new StringBuilder(); ExportCompressedLua(builder, list); STRUCTURE_COUNTS.Clear(); FUNCTION_SHORTCUTS.Clear(); return(builder); }
/// <summary> /// Export the data to the builder in a raw, longhand format. /// Standardized formatting applies here. /// </summary> /// <param name="data">The undetermined object data.</param> /// <returns>A built string containing the information.</returns> public static StringBuilder ExportCompressedLua(object data) { var builder = new StringBuilder(); ExportCompressedLua(builder, data); STRUCTURE_COUNTS.Clear(); FUNCTION_SHORTCUTS.Clear(); return(builder); }