Example #1
0
        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);
            }
        }
Example #2
0
 public T ToDelegate <T>() where T : class
 {
     return(DelegateTraits <T> .Create(this) as T);
 }