RegisterClass() public static method

public static RegisterClass ( IntPtr hEnviroment, XLRTClassInfo info ) : void
hEnviroment System.IntPtr
info XLRTClassInfo
return void
Esempio n. 1
0
        public static void Register()
        {
            //
            //0、得到Lua环境句柄
            //
            var pNull       = new IntPtr(0);
            var hEnviroment = XLLuaRuntime.XLLRT_GetEnv(null);

            switch (_createPolicy)
            {
            case CreatePolicy.Factory:
                //1、注册类型工厂
                XLLuaRuntime.RegisterGlobalObject(hEnviroment, new XLRTObjectInfo
                {
                    ClassName   = _typeFactoryClassName,
                    ObjectName  = _typeFactoryObjectName,
                    UserData    = pNull,
                    GetFunction = _lua_GetClassFactoryInstance,
                    Methods     = new SortedList <string, LuaCFunction> {
                        { "CreateInstance", _lua_CreateInstance }
                    }
                });

                //2、注册类型
                XLLuaRuntime.RegisterClass(hEnviroment, new XLRTClassInfo
                {
                    ClassName       = _typeFullName,
                    FatherClassName = null,
                    DeleteFunction  = _lua_DeleteInstance,
                    Methods         = _lua_functions
                });
                return;

            case CreatePolicy.Singleton:
                //1、注册单例对象
                XLLuaRuntime.RegisterGlobalObject(hEnviroment, new XLRTObjectInfo
                {
                    ClassName   = _typeFullName,
                    ObjectName  = _typeFullName,
                    UserData    = pNull,
                    GetFunction = _lua_GetClassFactoryInstance,
                    Methods     = _lua_functions
                });
                return;

            default:
                throw new Exception("UnSupport CreatePolicy!");
            }
        }
Esempio n. 2
0
        public static void Register()
        {
            //
            //0、得到Lua环境句柄
            //
            //var pNull = new IntPtr(0);
            var hEnviroment = XLLuaRuntime.XLLRT_GetEnv(null);

            //1、注册类型
            XLLuaRuntime.RegisterClass(hEnviroment, new XLRTClassInfo
            {
                ClassName       = _typeFullName,
                FatherClassName = null,
                DeleteFunction  = _lua_DeleteInstance,
                Methods         = _lua_functions
            });
        }