Exemplo n.º 1
0
        static int getPropertyByName(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String))
            {
                Lua.Lua_pushnil(L);
                return(1);
            }

            Object tag      = (Object)Lua.Lua_touserdata(L, 1);
            String arrtName = Lua.Lua_tostring(L, 2).ToString();

            if (string.IsNullOrEmpty(arrtName))
            {
                RYTLog.ShowMessage("getPropertyByName()参数不能为空!");
                Lua.Lua_pushnil(L);
                return(0);
            }

            object resultValue = null;

            try
            {
                resultValue = RYTKeyMapping.Instance.DoReflection(arrtName, tag, null, ReflectionType.Get);
            }
            catch (Exception e)
            {
                Debug.WriteLine("RYTKeyMapping.Instance.DoReflection() error .." + e.Message ?? "");
            }
            if (resultValue != null)
            {
                Lua.Lua_pushstring(L, resultValue.ToString());
                return(1);
            }
            else
            {
                Lua.Lua_pushstring(L, string.Empty);
            }

            return(1);
        }
Exemplo n.º 2
0
        static int setAttribute(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String, LConst.String))
            {
                return(0);
            }

            Object tag   = (Object)Lua.Lua_touserdata(L, 1);
            String name  = Lua.Lua_tostring(L, 2).ToString();
            String value = Lua.Lua_tostring(L, 3).ToString();

            var setResult = RYTKeyMapping.Instance.DoReflection(name, tag, value, ReflectionType.Set);

            if (setResult == null || setResult.ToString().Equals("true"))
            {
                RYTLog.ShowMessage(string.Format("在Control:[{0}]上设置属性为:[{1}]的值:[{2}]失败!", tag.ToString(), name, value),
                                   "LuaElement:setAttribute()");
            }


            return(0);
        }