Ejemplo n.º 1
0
        /// <summary>
        /// Execute script scenario
        /// </summary>
        /// <param name="id">scenario id</param>
        /// <param name="server">server that implements scenario operations</param>
        /// <returns></returns>
        public bool Execute(int id, IScriptingServer server)
        {
            object executorObject = compiledAssembly.CreateInstance("Utils.CompileScripts._Executor");

            ((ScriptingBase)executorObject).Initialize(server);
            MethodInfo mi = executorObject.GetType().GetMethod("GetScenarioDelegate" + id);

            ScriptingBase.ScenarioDelegate executor = (ScriptingBase.ScenarioDelegate)mi.Invoke(executorObject, null);

            try
            {
                executor();
            }
            catch (ScriptingException e)
            {
                server.SetFailureReason(e.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialize ScriptingBase instance
 /// </summary>
 /// <param name="server">IScriptingServer interface</param>
 public void Initialize(IScriptingServer server)
 {
     this.server = server;
 }