Beispiel #1
0
        public IMacroResult Run(object appDisp, string macroPath, string moduleName,
                                string subName, int opts, IMacroParameter param, bool cacheReg = false)
        {
            var app = CastApplication(appDisp);

            var macro = app.OpenMacro(macroPath);

            GetMacroParametersManager(true, out RotRegister newReg, out IMacroParameterManager macroParamsMgr);

            if (newReg != null)
            {
                if (cacheReg)
                {
                    if (m_Register != null)
                    {
                        try
                        {
                            m_Register.Dispose();
                        }
                        catch (Exception ex)
                        {
                            m_Logger.Log(ex);
                        }
                    }

                    m_Register = newReg;
                }
            }

            try
            {
                var sessionId = CreateMacroSessionId(app, macro);
                macroParamsMgr.PushParameter(sessionId, param);

                try
                {
                    macro.Run(new MacroEntryPoint(moduleName, subName), (MacroRunOptions_e)opts);
                }
                finally
                {
                    macroParamsMgr.TryRemoveParameter(sessionId, param);
                }
            }
            finally
            {
                if (newReg != null && !cacheReg)
                {
                    newReg.Dispose();
                }
            }

            return(param.Result);
        }
Beispiel #2
0
 public void Dispose()
 {
     m_Register?.Dispose();
 }