public static object[] RunScript(string script, ExternalCommandData commandData, ElementSet elements, bool createTransaction) { if (createTransaction) { return(null); } else { Lua state = new Lua(); state.LoadCLRPackage(); state["commandData"] = commandData; state["elements"] = elements; try { var r = state.DoString(script); state.Dispose(); return(r); } catch (NLua.Exceptions.LuaScriptException lse) { object[] obj = new object[2]; obj[0] = lse.Message; obj[1] = lse.Source; state.Dispose(); return(obj); } } }
public void Dispose_CalledTwice() { var lua = new Lua(); lua.Dispose(); lua.Dispose(); }
private void EndScript() { _scriptL["RUNNING__"] = false; System.Threading.Thread.Sleep(500); _scriptL.Close(); _scriptL.Dispose(); Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); }
[TestMethod] public void DisposeLua() { GcUtil.ExecuteAndKill(() => { var lua = new Lua(); var gc = new GcUtil.GCTest(lua); lua.Dispose(); lua.Dispose(); return(gc); }); }
[TestMethod] public void DisposeLuaTableAfterLua() { GcUtil.ExecuteAndKill(() => { var lua = new Lua(); var table = lua.NewTable(); var gc = new GcUtil.GCTest(table); lua.Dispose(); lua.Dispose(); table.Dispose(); table.Dispose(); return(gc); }); }
private void Dispose(bool disposeManaged) { if (m_disposed || !m_initialized) { return; } if (disposeManaged) { m_track.Dispose(); m_population.Dispose(); m_overviewView.Dispose(); m_overviewWindow.Dispose(); m_drawingView.Dispose(); m_drawingWindow.Dispose(); m_window.Dispose(); if (m_luaState != null) { m_luaState.Dispose(); } } m_disposed = true; }
protected virtual void Dispose(bool disposing) { if (pLuaVM != null) { pLuaVM.Dispose(); } }
private Lua NewTest() { var lua = new Lua(); try { lua.DoString(@" function newTestTable(meta_read, meta_write) local meta = {} if meta_read then meta.__index = function(t,k) return 'metatable read' end end if meta_write then meta.__newindex = function(t,k,v) rawset(t,k, 'metatable write') end end return setmetatable({ 1, 2, 3, 4, 5, 6, -- array one = 1, -- associative array two = 2, three = 3, four = 4, five = 5, SIX = 6, six = 'wrong', [1/2] = 'half', -- double key nested = {a={b= setmetatable({c='hi'},meta) }}, }, meta ) end " , "@Table.cs.NewTest.lua"); // chunk names beginning with @ are filenames } catch (Exception) { lua.Dispose(); throw; } return(lua); }
protected virtual void Dispose(bool disposing) { if (disposing) { lua.Dispose(); } }
public void Dispose() { Lua lua = GetLua(); lua.Dispose(); _dbContext.Dispose(); }
private void ParseShellItem() { if (skipParsing) { return; } if (luascript is null || luascript == "") { throw new Exception("No Lua script provided"); } // better way to check for validity? if (!luascript.Contains("properties:Add")) { throw new Exception("There is no properties table in this Lua script to get information from"); } try { state.DoString(@luascript); } catch (Exception ex) { logger.Error(ex, "Error with a Lua script.\n" + ex.ToString()); } state.Dispose(); }
public void Init() { if (IsInitialized) { throw new InvalidOperationException("Already Initialized!"); } if (_state != null) { _state.Dispose(); } _state = new Lua(); _state.LoadCLRPackage(); _state.DoString(@"luanet.load_assembly('WGestures.Core'); luanet.load_assembly('WindowsInput'); luanet.load_assembly('WGestures.Common'); GestureModifier=luanet.import_type('WGestures.Core.GestureModifier'); VK=luanet.import_type('WindowsInput.Native.VirtualKeyCode'); Native=luanet.import_type('WGestures.Common.OsSpecific.Windows.Native'); ", "_init"); _state["Input"] = Sim.Simulator; _state.RegisterFunction("ReportStatus", this, typeof(ScriptCommand).GetMethod("OnReportStatus")); if (InitScript != null) { DoString(InitScript, "Init"); } IsInitialized = true; }
public void Dispose() { GC.SuppressFinalize(this); if (myLua != null) { myLua.Dispose(); } }
public void CreateFunctionDelegate_Disposed_ThrowsObjectDispossedException() { var lua = new Lua(); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua.CreateFunction(new Action(() => lua.Dispose()))); }
public void DoString_Disposed_ThrowsObjectDisposedException() { var lua = new Lua(); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua.DoString("")); }
public void CreateTable_Disposed_ThrowsObjectDisposedException() { var lua = new Lua(); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua.CreateTable()); }
protected virtual void OnDestroy() { Call("OnDestroy"); UnRegister(name + id); env.Dispose(); env = null; current = null; }
public void ImportType_Disposed_ThrowsObjectDisposedException() { var lua = new Lua(); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua.ImportType(typeof(int))); }
public static void CleanLuaEnv() { if (lua != null) { lua.Dispose(); lua = null; } }
public void GetGlobal_NullName_ThrowsArgumentNullException() { var lua = new Lua(); lua.Dispose(); Assert.Throws <ArgumentNullException>(() => lua[null]); }
public void GetDynamicMemberNames_Disposed_ThrowsObjectDisposedException() { dynamic lua = new Lua(); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua.GetDynamicMemberNames()); }
public void SetDynamic_Disposed_ThrowsObjectDisposedException() { dynamic lua = new Lua(); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua.x = 5); }
public void CreateFunctionDelegate_NullDelegate_ThrowsArgumentNullException() { var lua = new Lua(); lua.Dispose(); Assert.Throws <ArgumentNullException>(() => lua.CreateFunction((Delegate)null)); }
public void ImportNamespace_Disposed_ThrowsObjectDisposedException() { var lua = new Lua(); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua.ImportNamespace("System")); }
public void SetGlobal_Disposed_ThrowsObjectDisposedException() { var lua = new Lua(); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua["x"] = 10); }
public void Release() { ActiveEngine?.Release(); ActiveEngine = null; _lua.Dispose(); _lua = null; }
protected override void OnDestroy() { if (luaScript != null) { luaScript.Dispose(); } base.OnDestroy(); }
public void Dispose() { if (Lua == null) { return; } Lua.Dispose(); Lua = null; }
public virtual void Dispose() { if (_disposed) { return; } _disposed = true; _lua.Dispose(); }
public void CreateThread_Disposed_ThrowsObjectDisposedException() { var lua = new Lua(); var function = lua.CreateFunction("return 0"); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua.CreateThread(function)); }
public LuaInstance() { lua = new Lua(); packages = new HashSet<string>(); try { global = lua.CreateEnvironment(); global["package.path"] = LuaConfig.PackagePath; LuaAerospike.LoadLibrary(this); LuaStream.LoadLibrary(this); Assembly assembly = Assembly.GetExecutingAssembly(); LoadSystemPackage(assembly, "aslib"); LoadSystemPackage(assembly, "stream_ops"); LoadSystemPackage(assembly, "aerospike"); } catch (Exception) { lua.Dispose(); throw; } }