本文整理汇总了C#中NLua.Lua.RegisterLuaClassType方法的典型用法代码示例。如果您正苦于以下问题:C# Lua.RegisterLuaClassType方法的具体用法?C# Lua.RegisterLuaClassType怎么用?C# Lua.RegisterLuaClassType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NLua.Lua
的用法示例。
在下文中一共展示了Lua.RegisterLuaClassType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterNLuaBox
public static void RegisterNLuaBox(Lua context)
{
context.RegisterLuaDelegateType (typeof (EventHandler<EventArgs>), typeof (LuaEventArgsHandler));
context.RegisterLuaDelegateType (typeof (EventHandler), typeof (LuaEventArgsHandler));
context.RegisterLuaDelegateType (typeof (EventHandler<UIButtonEventArgs>), typeof (LuaButtonEventArgsHandler));
context.RegisterLuaDelegateType (typeof(NSAction), typeof(LuaNSActionHandler));
context.RegisterLuaClassType (typeof (UIViewController), typeof (NLuaBoxUIViewControllerBinder));
context.RegisterLuaClassType (typeof (UITableViewSource), typeof (NLuaBoxUITableViewSourceBinder));
context.RegisterLuaClassType (typeof (JLTextViewController), typeof (NLuaBoxDetailLuaViewController));
context.RegisterLuaClassType (typeof (DialogViewController), typeof (NLuaBoxDialogViewControllerBinder));
context.RegisterLuaClassType (typeof (UITableViewController), typeof (NLuaBoxUITableViewControllerBinder));
context.RegisterFunction ("CreateListString", typeof (NLuaBoxBinder).GetMethod ("CreateListString"));
}
示例2: RegisterNLuaBox
public static void RegisterNLuaBox(Lua context)
{
context.RegisterLuaDelegateType (typeof (EventHandler<EventArgs>), typeof (LuaEventArgsHandler));
context.RegisterLuaDelegateType (typeof (EventHandler), typeof (LuaEventArgsHandler));
context.RegisterLuaDelegateType (typeof (EventHandler<UIButtonEventArgs>), typeof (LuaButtonEventArgsHandler));
context.RegisterLuaClassType (typeof (UIViewController), typeof (NLuaBoxUIViewControllerBinder));
}
示例3: LuaTableBaseMethod
public void LuaTableBaseMethod ()
{
using (Lua lua = new Lua ()) {
lua.RegisterLuaClassType (typeof(TestClass), typeof(LuaTestClassHandler));
lua.DoString ("luanet.load_assembly('NLuaTest')");
lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
lua.DoString ("test={}");
lua.DoString ("function test:overridableMethod(x,y) print(self[base]); return 6 end");
lua.DoString ("luanet.make_object(test,'NLuaTest.Mock.TestClass')");
lua.DoString ("a=TestClass.callOverridable(test,2,3)");
int a = (int)lua.GetNumber ("a");
lua.DoString ("luanet.free_object(test)");
Assert.AreEqual (6, a);
// lua.DoString("luanet.load_assembly('NLuaTest')");
// lua.DoString("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
// lua.DoString("test={}");
//
// lua.DoString("luanet.make_object(test,'NLuaTest.Mock.TestClass')");
// lua.DoString ("function test.overridableMethod(test,x,y) return 2*test.base.overridableMethod(test,x,y); end");
// lua.DoString("a=TestClass.callOverridable(test,2,3)");
// int a = (int)lua.GetNumber("a");
// lua.DoString("luanet.free_object(test)");
// Assert.AreEqual(10, a);
//Console.WriteLine("interface returned: "+a);
}
}
示例4: NLuaAAValueTypes
public void NLuaAAValueTypes ()
{
using (Lua lua = new Lua ()) {
lua.RegisterLuaClassType (typeof(ITest), typeof(LuaITestClassHandler));
lua.DoString ("luanet.load_assembly('NLuaTest')");
lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
lua.DoString ("test=TestClass()");
lua.DoString ("itest={}");
lua.DoString ("function itest:test1(x,y) return x+y; end");
lua.DoString ("test=TestClass()");
lua.DoString ("a=test:callInterface1(itest)");
int a = (int)lua.GetNumber ("a");
Assert.AreEqual (5, a);
//Console.WriteLine("interface returned: "+a);
}
}