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); } } }
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); } } }