Esempio n. 1
0
 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);
         }
     }
 }
Esempio n. 2
0
        public void Dispose_CalledTwice()
        {
            var lua = new Lua();

            lua.Dispose();
            lua.Dispose();
        }
Esempio n. 3
0
 private void EndScript()
 {
     _scriptL["RUNNING__"] = false;
     System.Threading.Thread.Sleep(500);
     _scriptL.Close();
     _scriptL.Dispose();
     Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
 }
Esempio n. 4
0
 [TestMethod] public void DisposeLua()
 {
     GcUtil.ExecuteAndKill(() =>
     {
         var lua = new Lua();
         var gc  = new GcUtil.GCTest(lua);
         lua.Dispose();
         lua.Dispose();
         return(gc);
     });
 }
Esempio n. 5
0
 [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);
     });
 }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
 protected virtual void Dispose(bool disposing)
 {
     if (pLuaVM != null)
     {
         pLuaVM.Dispose();
     }
 }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         lua.Dispose();
     }
 }
Esempio n. 10
0
        public void Dispose()
        {
            Lua lua = GetLua();

            lua.Dispose();
            _dbContext.Dispose();
        }
Esempio n. 11
0
        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();
        }
Esempio n. 12
0
        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;
        }
Esempio n. 13
0
 public void Dispose()
 {
     GC.SuppressFinalize(this);
     if (myLua != null)
     {
         myLua.Dispose();
     }
 }
Esempio n. 14
0
        public void CreateFunctionDelegate_Disposed_ThrowsObjectDispossedException()
        {
            var lua = new Lua();

            lua.Dispose();

            Assert.Throws <ObjectDisposedException>(() => lua.CreateFunction(new Action(() => lua.Dispose())));
        }
Esempio n. 15
0
        public void DoString_Disposed_ThrowsObjectDisposedException()
        {
            var lua = new Lua();

            lua.Dispose();

            Assert.Throws <ObjectDisposedException>(() => lua.DoString(""));
        }
Esempio n. 16
0
        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;
 }
Esempio n. 18
0
        public void ImportType_Disposed_ThrowsObjectDisposedException()
        {
            var lua = new Lua();

            lua.Dispose();

            Assert.Throws <ObjectDisposedException>(() => lua.ImportType(typeof(int)));
        }
Esempio n. 19
0
 public static void CleanLuaEnv()
 {
     if (lua != null)
     {
         lua.Dispose();
         lua = null;
     }
 }
Esempio n. 20
0
        public void GetGlobal_NullName_ThrowsArgumentNullException()
        {
            var lua = new Lua();

            lua.Dispose();

            Assert.Throws <ArgumentNullException>(() => lua[null]);
        }
Esempio n. 21
0
        public void GetDynamicMemberNames_Disposed_ThrowsObjectDisposedException()
        {
            dynamic lua = new Lua();

            lua.Dispose();

            Assert.Throws <ObjectDisposedException>(() => lua.GetDynamicMemberNames());
        }
Esempio n. 22
0
        public void SetDynamic_Disposed_ThrowsObjectDisposedException()
        {
            dynamic lua = new Lua();

            lua.Dispose();

            Assert.Throws <ObjectDisposedException>(() => lua.x = 5);
        }
Esempio n. 23
0
        public void CreateFunctionDelegate_NullDelegate_ThrowsArgumentNullException()
        {
            var lua = new Lua();

            lua.Dispose();

            Assert.Throws <ArgumentNullException>(() => lua.CreateFunction((Delegate)null));
        }
Esempio n. 24
0
        public void ImportNamespace_Disposed_ThrowsObjectDisposedException()
        {
            var lua = new Lua();

            lua.Dispose();

            Assert.Throws <ObjectDisposedException>(() => lua.ImportNamespace("System"));
        }
Esempio n. 25
0
        public void SetGlobal_Disposed_ThrowsObjectDisposedException()
        {
            var lua = new Lua();

            lua.Dispose();

            Assert.Throws <ObjectDisposedException>(() => lua["x"] = 10);
        }
Esempio n. 26
0
        public void Release()
        {
            ActiveEngine?.Release();
            ActiveEngine = null;

            _lua.Dispose();
            _lua = null;
        }
Esempio n. 27
0
        protected override void OnDestroy()
        {
            if (luaScript != null)
            {
                luaScript.Dispose();
            }

            base.OnDestroy();
        }
Esempio n. 28
0
 public void Dispose()
 {
     if (Lua == null)
     {
         return;
     }
     Lua.Dispose();
     Lua = null;
 }
Esempio n. 29
0
 public virtual void Dispose()
 {
     if (_disposed)
     {
         return;
     }
     _disposed = true;
     _lua.Dispose();
 }
Esempio n. 30
0
        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;
            }
        }