コード例 #1
0
ファイル: Table.cs プロジェクト: weimingtom/MonoBoxedLua
        [LuaGlobal] public static void ConsumeBigTable(LuaTable t)
        {
            t.ForEachI((i, value) =>
            {
                var row   = (LuaTable)value;
                var field = (LuaTable)row["vector"];
                Eat((double)field[1]); Eat((double)field.RawGet(1)); Eat((int)field.GetValue(1)); Eat((int)field.RawGetValue(1));
                Eat((double)field[2]); Eat((double)field.RawGet(2)); Eat <double>(field.GetValue(2)); Eat <double>(field.RawGetValue(2));
                Eat((string)field[3]); Eat((string)field.RawGet(3)); Eat <string>(field.GetValue(3)); Eat <string>(field.RawGetValue(3));
                field.Dispose();

                field = (LuaTable)row["obj"];
                Eat((double)field["a"]); Eat((double)field.RawGet("a")); Eat((int)field.GetValue("a")); Eat((int)field.RawGetValue("a"));
                Eat((double)field["b"]); Eat((double)field.RawGet("b")); Eat <double>(field.GetValue("b")); Eat <double>(field.RawGetValue("b"));
                Eat((string)field["c"]); Eat((string)field.RawGet("c")); Eat <string>(field.GetValue("c")); Eat <string>(field.RawGetValue("c"));
                field.Dispose();

                Eat((double)row["int"]); Eat((double)row.RawGet("int")); Eat <double>(row.GetValue("int")); Eat <double>(row.RawGetValue("int"));
                Eat((double)row["double"]); Eat((double)row.RawGet("double")); Eat <double>(row.GetValue("double")); Eat <double>(row.RawGetValue("double"));
                Eat((string)row["string"]); Eat((string)row.RawGet("string")); Eat <string>(row.GetValue("string")); Eat <string>(row.RawGetValue("string"));
                Eat((bool)row["bool"]); Eat((bool)row.RawGet("bool")); Eat <bool>(row.GetValue("bool")); Eat <bool>(row.RawGetValue("bool"));
                Eat((System.Text.Encoding)row["userdata"]); Eat((System.Text.Encoding)row.RawGet("userdata")); Assert.AreEqual(LuaType.UserData, row.GetValue("userdata").Type); Assert.AreEqual(LuaType.UserData, row.RawGetValue("userdata").Type);
                Eat((double)row["rawset"]); Eat((double)row.RawGet("rawset")); Eat((int)row.GetValue("rawset")); Eat((int)row.RawGetValue("rawset"));

                row.Dispose();
            });
            t.Dispose();
        }