当前位置: 首页>>代码示例>>C#>>正文


C# Lua.RegisterLuaDelegateType方法代码示例

本文整理汇总了C#中NLua.Lua.RegisterLuaDelegateType方法的典型用法代码示例。如果您正苦于以下问题:C# Lua.RegisterLuaDelegateType方法的具体用法?C# Lua.RegisterLuaDelegateType怎么用?C# Lua.RegisterLuaDelegateType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NLua.Lua的用法示例。


在下文中一共展示了Lua.RegisterLuaDelegateType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.RegisterLuaClassType (typeof (UIViewController), typeof (NLuaBoxUIViewControllerBinder));
        }
开发者ID:kumpera,项目名称:NLuaBox,代码行数:8,代码来源:NLuaBoxBinder.cs

示例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.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"));
        }
开发者ID:JackFong,项目名称:NLuaBox,代码行数:15,代码来源:NLuaBoxBinder.cs

示例3: RegisterNLuaDelegate

    public static void RegisterNLuaDelegate(Lua context)
    {
        //Only For IOS 
        context.RegisterLuaDelegateType(typeof(EventTriggerListener.VoidDelegate), typeof(CallbackLuaFunction<GameObject>));

        context.RegisterLuaDelegateType(typeof(Action<object>), typeof(CallbackLuaFunction<object>));
        context.RegisterLuaDelegateType(typeof(Action), typeof(CallbackLuaFunction));
        context.RegisterLuaDelegateType(typeof(Callback), typeof(CallbackLuaFunction));
        context.RegisterLuaDelegateType(typeof(Callback<object>), typeof(CallbackLuaFunction<object>));
        context.RegisterLuaDelegateType(typeof(Callback<string, AssetBundle>), typeof(CallbackLuaFunction<string, AssetBundle>));
    }
开发者ID:hanbim520,项目名称:UFLua,代码行数:11,代码来源:LuaBinder.cs

示例4: TestEventException

		public void TestEventException ()
		{
			using (Lua lua = new Lua ()) {
				//Register a C# function
				MethodInfo testException = this.GetType ().GetMethod ("_TestException", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance, null, new Type [] {
                                typeof(float),
                                typeof(float)
                        }, null);
				lua.RegisterFunction ("Multiply", this, testException);
				lua.RegisterLuaDelegateType (typeof(EventHandler<EventArgs>), typeof(LuaEventArgsHandler));
				//create the lua event handler code for the entity
				//includes the bad code!
				lua.DoString ("function OnClick(sender, eventArgs)\r\n" +
					"--Multiply expects 2 floats, but instead receives 2 strings\r\n" +
					"Multiply(asd, es)\r\n" +
					"end");
				//create the lua event handler code for the entity
				//good code
				//lua.DoString("function OnClick(sender, eventArgs)\r\n" +
				//              "--Multiply expects 2 floats\r\n" +
				//              "Multiply(2, 50)\r\n" +
				//            "end");
				//Create the event handler script
				lua.DoString ("function SubscribeEntity(e)\r\ne.Clicked:Add(OnClick)\r\nend");
				//Create the entity object
				Entity entity = new Entity ();
				//Register the entity object with the event handler inside lua
				LuaFunction lf = lua.GetFunction ("SubscribeEntity");
				lf.Call (new object [1] { entity });

				try {
					//Cause the event to be fired
					entity.Click ();
					//failed
                    Assert.AreEqual(true, false);
				} catch (LuaException) {
					//passed
					Assert.AreEqual (true, true);
				}
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:41,代码来源:LuaTests.cs

示例5: LuaDelegateReferenceTypesByRefParam

		public void LuaDelegateReferenceTypesByRefParam ()
		{
			using (Lua lua = new Lua ()) {
				lua.RegisterLuaDelegateType (typeof(TestDelegate7), typeof(LuaTestDelegate7Handler));
				lua.DoString ("luanet.load_assembly('NLuaTest')");
				lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
				lua.DoString ("test=TestClass()");
				lua.DoString ("function func(x,y) return TestClass(x+y.testval); end");
				lua.DoString ("a=test:callDelegate7(func)");
				int a = (int)lua.GetNumber ("a");
				Assert.AreEqual (5, a);
				//Console.WriteLine("delegate returned: "+a);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:14,代码来源:LuaTests.cs

示例6: LuaDelegateValueTypesOutParam

		public void LuaDelegateValueTypesOutParam ()
		{
			using (Lua lua = new Lua ()) {
				lua.RegisterLuaDelegateType (typeof(TestDelegate2), typeof(LuaTestDelegate2Handler));
				lua.DoString ("luanet.load_assembly('NLuaTest')");
				lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
				lua.DoString ("test=TestClass()");
				lua.DoString ("function func(x) return x,x*2; end");
				lua.DoString ("test=TestClass()");
				lua.DoString ("a=test:callDelegate2(func)");
				int a = (int)lua.GetNumber ("a");
				Assert.AreEqual (6, a);
				//Console.WriteLine("delegate returned: "+a);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:15,代码来源:LuaTests.cs

示例7: RegisterNLuaDelegate

 public static void RegisterNLuaDelegate(Lua context)
 {
     //主要针对ios,aot下不能有动态模板映射,当kera模式在ios发布平台的时候
     context.RegisterLuaDelegateType(typeof(EventListener.VoidDelegate), typeof(CallbackLuaFunction<GameObject>));
     context.RegisterLuaDelegateType(typeof(Action<object>), typeof(CallbackLuaFunction<object>));
     context.RegisterLuaDelegateType(typeof(Action), typeof(CallbackLuaFunction));
     context.RegisterLuaDelegateType(typeof(Callback), typeof(CallbackLuaFunction));
     context.RegisterLuaDelegateType(typeof(Callback<object>), typeof(CallbackLuaFunction<object>));
     context.RegisterLuaDelegateType(typeof(Callback<string, AssetBundle>), typeof(CallbackLuaFunction<string, AssetBundle>));
     context.RegisterLuaDelegateType(typeof(DownloadProgressChangedEventHandler), typeof(CallbackLuaFunction<object, DownloadProgressChangedEventArgs>));
     context.RegisterLuaDelegateType(typeof(AsyncCompletedEventHandler), typeof(CallbackLuaFunction<object, AsyncCompletedEventArgs>));
     context.RegisterLuaDelegateType(typeof(UploadProgressChangedEventHandler), typeof(CallbackLuaFunction<object, UploadProgressChangedEventArgs>));
     context.RegisterLuaDelegateType(typeof(UploadStringCompletedEventHandler), typeof(CallbackLuaFunction<object, UploadStringCompletedEventArgs>));
 }
开发者ID:fankidark,项目名称:ME_NLua,代码行数:14,代码来源:API.cs


注:本文中的NLua.Lua.RegisterLuaDelegateType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。