xlua的util.createdelegate应用

local util = require 'xlua.util'
local obj = CS.TestClass()
local d1 = util.createdelegate(CS.System.Type.GetType('TestClass+TestDelegate'), obj, CS.TestClass, 'Foo', {typeof(CS.System.Int32)})
print(d1)
local type2 = CS.System.Type.GetType('TabButtonInfo+CanClick')
local d2 = util.createdelegate(type2, obj, CS.TestClass, 'CanClick', {})
print(d2)
local type3 = CS.System.Type.GetType('NoticeTweenPosition+EventTrigger')
local d3 = util.createdelegate(type3, obj, CS.TestClass, 'Trigger', {})
print(d3)
local type4 = CS.System.Type.GetType('NoticeTweenPosition+Finished')
local d4 = util.createdelegate(type4, obj, CS.TestClass, 'Trigger', {})
print(d4)
local type5 = CS.System.Type.GetType('BaseItemContext+OnPress')
local d5 = util.createdelegate(type5, obj, CS.TestClass, 'OnPress', {typeof(CS.BaseItemContext)})
print(d5)
local type6 = CS.System.Type.GetType('PageGodPvp+Action')
local d6 = util.createdelegate(type6, obj, CS.TestClass, 'Action', {typeof(CS.System.Single)})
print(d6)
local type7 = CS.System.Type.GetType('UICustomCheckbox+OnStateChange')
local d7 = util.createdelegate(type7, obj, CS.TestClass, 'OnStateChange', {typeof(CS.System.Boolean)})
print(d7)
local type8 = CS.System.Type.GetType('Tools+Action')
local d8 = util.createdelegate(type8, obj, CS.TestClass, 'Action', {typeof(CS.System.Single)})
print(d8)
local type9 = CS.System.Type.GetType('System.Action`1[System.Int32]')
local d9 = util.createdelegate(type9, obj, CS.TestClass, 'Foo', {typeof(CS.System.Int32)})
print(d9)
local type10 = CS.System['Action`2[System.Int32,System.Int32]']
local d10 = util.createdelegate(type10, obj, CS.TestClass, 'ActionIntInt', {typeof(CS.System.Int32),typeof(CS.System.Int32)})
print(d10)
local type11 = CS.System.Type.GetType('System.Action`2[[AI,Assembly-CSharp],[AI,Assembly-CSharp]],System.Core')
local d11 = util.createdelegate(type11, obj, CS.TestClass, 'ActionAiAi', {typeof(CS.AI),typeof(CS.AI)})
print(d11)
local type12 = CS.System.Type.GetType('System.Action`2[[System.String, mscorlib],[UnityEngine.Vector3, UnityEngine]],System.Core')

local dic = CS.System.Activator.CreateInstance(CS.System.Type.GetType('System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UnityEngine.Vector3, UnityEngine]],mscorlib'))
dic:Add('a', CS.UnityEngine.Vector3(1, 2, 3))
print(dic:TryGetValue('a'))


--C#
--public class TestClass
--{
-- public void Foo(int a){}
-- public delegate void TestDelegate(int a);
-- public string CanClick(){return string.Empty;}
-- public void Trigger(){ }
-- public void OnPress(BaseItemContext item){}
-- public void Action(float time){}
-- public void OnStateChange(bool flag){}
-- public void ActionIntInt(int a,int b){ }
-- public void ActionIntInt(AI a,AI b){ }
--}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值