public void WriteTableAsArrayTest() { luaWriter.WriteStartAssignment("numbers"); luaWriter.WriteStartTable(); for (int i = 0; i < 10; i++) { luaWriter.WriteStartTableField(); luaWriter.WriteLiteralExpression(i); luaWriter.WriteEndTableField(); } luaWriter.WriteEndTable(); luaWriter.WriteEndAssignment(); }
private void SerializeEnumerable(LuaWriter luaWriter, IEnumerable collection) { luaWriter.WriteStartTable(); foreach (var item in collection) { luaWriter.WriteStartTableField(); this.SerializeImpl(luaWriter, item); luaWriter.WriteEndTableField(); } luaWriter.WriteEndTable(); }
private void SerializeDictionary(LuaWriter luaWriter, object o) { Type type = o.GetType(); luaWriter.WriteStartTable(); foreach (var propertyInfo in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { luaWriter.WriteStartTableField(propertyInfo.Name, false); this.SerializeImpl(luaWriter, propertyInfo.GetValue(o, null)); luaWriter.WriteEndTableField(); } luaWriter.WriteEndTable(); }