private void InitLuaGlobalParameter(LuaApiRegister luaHelper, NameValueCollection parameters)
 {
     foreach (var item in parameters.AllKeys)
     {
         luaHelper.ExecuteString("a_" + item.Trim() + " = \"" + parameters[item].Replace("\\", "\\\\") + "\";");
     }
 }
        private void ExecuteFile(LuaApiRegister luaHelper, string luaFileName)
        {
            try
            {
                _throwMessage = "";
                _returnCode   = null;
                luaHelper.ExecuteFile(luaFileName);
            }
            catch (ReturnCode returnCode)
            {
                _returnCode = returnCode;
            }
            catch (Exception ex)
            {
                _throwMessage = ex.Message;
            }

            if (_returnCode != null)
            {
                throw _returnCode;
            }
            else if (string.IsNullOrEmpty(_throwMessage))
            {
                Logger.Info("脚本执行完毕:" + luaFileName);
            }
            else if (!string.IsNullOrEmpty(_throwMessage))
            {
                Logger.Error(_throwMessage);
                throw new Exception(_throwMessage);
            }
        }
        public void ExecuteScript(string scriptName, NameValueCollection parameters)
        {
            if (!File.Exists(Path.Combine(_scriptRoot, scriptName + ".lua")))
            {
                throw new FileNotFoundException();
            }

            LuaApiRegister luaHelper = new LuaApiRegister(new TestLuaApiInterface());

            InitLuaGlobalParameter(luaHelper, parameters);

            ExecuteFile(luaHelper, Path.Combine(_scriptRoot, scriptName + ".lua"));
        }