示例#1
0
        private void Sandbox(Action callback, Action exceptionCallback)
        {
            string savedEnvironmentCurrDir = null;

            try
            {
                savedEnvironmentCurrDir = Environment.CurrentDirectory;

                if (_currentDirectory != null)
                {
                    CoolSetCurrentDirectory(_currentDirectory, savedEnvironmentCurrDir);
                }

                EnvironmentSandbox.Sandbox(callback);
            }
            catch (NLua.Exceptions.LuaException ex)
            {
                Console.WriteLine(ex);
                DefaultLogger(ex.ToString());
                exceptionCallback?.Invoke();
            }
            finally
            {
                if (_currentDirectory != null)
                {
                    CoolSetCurrentDirectory(savedEnvironmentCurrDir);
                }
            }
        }
示例#2
0
        void Sandbox(Action callback, Action exceptionCallback)
        {
            string savedEnvironmentCurrDir = null;

            try
            {
                savedEnvironmentCurrDir = Environment.CurrentDirectory;

                if (CurrentDirectory != null)
                {
                    CoolSetCurrentDirectory(CurrentDirectory, savedEnvironmentCurrDir);
                }

                EnvironmentSandbox.Sandbox(callback);
            }
            catch (LuaException ex)
            {
                Console.WriteLine(ex);
                Logger(ex.ToString());
                if (exceptionCallback != null)
                {
                    exceptionCallback();
                }
            }
            finally
            {
                if (CurrentDirectory != null)
                {
                    CoolSetCurrentDirectory(savedEnvironmentCurrDir);
                }
            }
        }