public static Delegate CheckDelegate <T>(IntPtr L, int stackPos) { LuaTypes luaTypes = LuaDLL.lua_type(L, stackPos); switch (luaTypes) { case LuaTypes.LUA_TNIL: return(null); case LuaTypes.LUA_TFUNCTION: LuaFunction func = ToLua.ToLuaFunction(L, stackPos); return(DelegateTraits <T> .Create(func)); case LuaTypes.LUA_TUSERDATA: return((Delegate)ToLua.CheckObject(L, stackPos, typeof(T))); default: return(null); } }
public T ToDelegate <T>() where T : class { return(DelegateTraits <T> .Create(this) as T); }