Наследование: System.Dynamic.DynamicObject, IDisposable
Пример #1
0
        //Main Entry Point for the Solution (Startup Project)
        //Just some random tests here. The real Unittests are in a seperate Project. See Readme for Details.
        static void Main(string[] args)
        {
            dynamic lua = new DynamicLua.DynamicLua();

            lua("c1 = { num = 42 }; c2 = { num = 7 }");
            lua("mtc = { __add = function(t, other) return t.num + other.num end }");
            lua("setmetatable(c1, mtc)");
            lua("setmetatable(c2, mtc)");

            Console.WriteLine(lua.c1 + lua.c2);

            lua.DoFile("test.lua");
            Console.WriteLine(lua.tab.test);

            dynamic tab = lua("return {a = 1, b = 2, c = 3}");
            lua.tab = tab;
            lua("print(type(tab))");
            lua("for k,v in pairs(tab) do print(k,v) end");

            //RawGet test
            dynamic mt = lua.NewTable("mt");
            //mt.__index = lua("return { a = 5 }");
            mt.__index = new Func<dynamic, dynamic, dynamic>((t, k) => 5);

            tab = lua.NewTable("tab");
            tab.a = 4;
            tab.SetMetatable(mt);

            Console.WriteLine(tab.b);

            Console.ReadKey(true);
        }
Пример #2
0
        //Main Entry Point for the Solution (Startup Project)
        //Just some random tests here. The real Unittests are in a seperate Project. See Readme for Details.
        static void Main(string[] args)
        {
            dynamic lua = new DynamicLua.DynamicLua();

            lua("c1 = { num = 42 }; c2 = { num = 7 }");
            lua("mtc = { __add = function(t, other) return t.num + other.num end }");
            lua("setmetatable(c1, mtc)");
            lua("setmetatable(c2, mtc)");

            Console.WriteLine(lua.c1 + lua.c2);

            lua.DoFile("test.lua");
            Console.WriteLine(lua.tab.test);

            dynamic tab = lua("return {a = 1, b = 2, c = 3}");

            lua.tab = tab;
            lua("print(type(tab))");
            lua("for k,v in pairs(tab) do print(k,v) end");

            //RawGet test
            dynamic mt = lua.NewTable("mt");

            //mt.__index = lua("return { a = 5 }");
            mt.__index = new Func <dynamic, dynamic, dynamic>((t, k) => 5);

            tab   = lua.NewTable("tab");
            tab.a = 4;
            tab.SetMetatable(mt);

            Console.WriteLine(tab.b);

            Console.ReadKey(true);
        }
Пример #3
0
        //Main Entry Point for the Solution (Startup Project)
        //Just some random tests here. The real Unittests are in a seperate Project. See Readme for Details.
        static void Main(string[] args)
        {
            dynamic lua = new DynamicLua.DynamicLua();

            lua("c1 = { num = 42 }; c2 = { num = 7 }");
            lua("mtc = { __add = function(t, other) return t.num + other.num end }");
            lua("setmetatable(c1, mtc)");
            lua("setmetatable(c2, mtc)");

            Console.WriteLine(lua.c1 + lua.c2);

            Console.ReadKey(true);
        }