Beispiel #1
0
        protected override void load()
        {
            subscribe(PluginShareHelper.DBPlugin_BroadCast_CheckTableNumberIsGreaterThan0, this);
            subscribe(MDT.Tools.Fix.Common.Utils.PluginShareHelper.BroadCastCheckFixNumberIsGreaterThan0, this);
            _dbContextMenuStrip = getObject(PluginShareHelper.DBPluginKey, PluginShareHelper.CmcSubPlugin) as ContextMenuStrip;
            fixCmcSubPlugin     = getObject(MDT.Tools.Fix.Common.Utils.PluginShareHelper.FixPluginKey, MDT.Tools.Fix.Common.Utils.PluginShareHelper.CmsSubPlugin) as ContextMenuStrip;
            AddContextMenu();
            ILuaEngine luaEngine = LuaHelper.CreateLuaEngine();

            luaEngine.BindLuaFunctions(this);
        }
Beispiel #2
0
        private void loadLuaScriptFile(string luaScriptPath, string pluginSign)
        {
            string[] files = Directory.GetFiles(luaScriptPath);
            foreach (string fileName in files)
            {
                if (fileName.EndsWith(pluginSign))
                {
                    try
                    {
                        ILuaEngine luaEngine = LuaHelper.CreateLuaEngine();
                        luaEngine.BindLuaFunctions(this);
                        //LogHelper.Debug(luaEngine.ToString());
                        luaEngine.DoFile(fileName);
                        object[] luaPa = luaEngine.Invoke("init");
                        if (luaPa != null && luaPa.Length == 6)
                        {
                            int temp = 0;
                            int tag = 0;
                            int pluginKey = 0;
                            if(int.TryParse(luaPa[0] + "", out temp))
                               tag = temp;

                            if (int.TryParse(luaPa[1] + "", out temp))
                            {
                                pluginKey = temp;
                            }
                            LuaScriptPlugin lsp = new LuaScriptPlugin(tag, pluginKey, luaPa[2] + "", luaPa[3] + "", luaPa[4] + "", luaPa[5] + "");
                            lsp.LuaEngine = luaEngine;
                            lsp.fileName = fileName.Replace(System.Windows.Forms.Application.StartupPath+"\\","");
                            lsp.Application = Application;
                            if (luaPlugins.ContainsKey(lsp.PluginKey))
                            {
                                luaPlugins.Remove(lsp.PluginKey);
                            }
                            luaPlugins.Add(lsp.PluginKey, lsp);
                            
                        }

                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error(string.Format("{0}:{1}",fileName,ex.StackTrace));
                    }
                }
            }
        }