internal ScriptCallContext(ScriptCallContext parent, IFileProcedure procedure, ContextLogOption callLoggingOption, bool isDynamicCall) { m_task = parent.m_task; m_parentContext = parent; m_taskManager = parent.m_taskManager; m_callLoggingOption = callLoggingOption; m_loggerOnEntry = parent.Logger; m_loggerInside = m_loggerOnEntry; m_statusUpdaterOnEntry = parent.StatusUpdater; m_loggingEnabled = parent.LoggingEnabled; m_errorListener = parent.m_errorListener; m_procedure = procedure; m_isDynamicCall = isDynamicCall; this.SetupFromProcedure(); m_currentReports = parent.m_currentReports; // Simply inherit the list. //m_createdlogger = logger.LogEntering(procedure.ElementName, procedure.Purpose); //if (separateStateLevel) //{ // m_currentStatusUpdater = parent.StatusUpdate.CreateSubTaskStatusReporter(procedure.Purpose); // m_currentStatusUpdater.Disposed += M_currentStatusUpdater_Disposed; // m_createdStatusUpdaters = new Stack<ITaskStatusUpdate>(4); // m_createdStatusUpdaters.Push(m_currentStatusUpdater); //} //else //{ // m_currentStatusUpdater = parent.StatusUpdate; //} }
//public object CallProcedure(IFileProcedure procedure, LoggerRoot logger, ContextLogOption callerLoggingOption, IExecutionScopeStatusUpdate statusUpdate, params object[] arguments) //{ // this.Setup(logger, callerLoggingOption, statusUpdate); // return this.DoCallProcedure(procedure, arguments); //} private object DoCallProcedure(IFileProcedure procedure, object[] arguments) { Delegate runtimeProcedure = ((FileProcedure)procedure).RuntimeProcedure; var invokeArguments = new object[arguments.Length + 1]; Array.Copy(arguments, 0, invokeArguments, 1, arguments.Length); ScriptCallContext context = null; try { context = new ScriptCallContext(this, m_logger, m_logOption, m_statusUpdate, procedure, m_taskManager); context.SetErrorListener(m_errorListener); invokeArguments[0] = context; m_value = runtimeProcedure.DynamicInvoke(invokeArguments); return(m_value); } catch (Exception) { throw; } finally { context.InternalDispose(); } }
public static IScriptExecution StartProcedureExecution(IFileProcedure procedure, params object[] arguments) { var execution = m_scriptExecutionManager.CreateFileElementExecution(procedure, null, arguments); execution.StartExecution(); return(execution); }
private static object DoDynamicInvoke(IFileProcedure procedure, bool debug, params object[] args) { var taskContext = ExeContext(); LoggerRoot.Root(taskContext.Logger).IsDebugging = debug; return(taskContext.CallProcedure(procedure, args)); }
public object CallProcedure(IFileProcedure procedure, params object[] arguments) { try { m_value = this.DoCallProcedure(procedure, arguments); return(m_value); } catch (Exception ex) { LoggerRoot.Root(this.Logger).DebugDump(); m_executionException = ex; return(null); } }
public static IFileProcedure TryFindProcedure(string name) { foreach (var file in m_loadedFilesManager.ListFiles <ScriptFile>()) { IFileProcedure procedure = file.ListElements().First( p => String.Equals(name, p.Name, StringComparison.InvariantCultureIgnoreCase) || String.Equals(name, p.FullName, StringComparison.InvariantCultureIgnoreCase)) as IFileProcedure; if (procedure != null) { return(procedure); } } return(null); }
internal ScriptCallContext( ScriptTaskContext task, ILogger logger, ContextLogOption callLoggingOption, IExecutionScopeStatusUpdate statusUpdater, IFileProcedure procedure, TaskManager taskManager) { m_task = task; m_parentContext = null; m_callLoggingOption = callLoggingOption; m_loggerInside = m_loggerOnEntry = logger; m_statusUpdaterOnEntry = statusUpdater; m_loggingEnabled = true; // Initial m_procedure = procedure; m_taskManager = taskManager; m_isDynamicCall = false; this.SetupFromProcedure(); }
public IScriptCallContext EnterNewScriptContext(IFileProcedure procedure, ContextLogOption procedureLoggingOption, bool isDynamicCall) { throw new NotImplementedException(); }
public virtual IScriptCallContext EnterNewScriptContext(IFileProcedure procedure, ContextLogOption callerLoggingOption, bool isDynamicCall) { return(new ScriptCallContext(this, procedure, callerLoggingOption, isDynamicCall)); }
public static object ExecuteProcedure(IFileProcedure procedure, params object[] arguments) { var result = m_scriptExecutionManager.ExecuteFileElement(procedure, null, arguments); return(result.ReturnValue); }
public FileElementPartner(IFileElement parent, string name, string referenceName, IFileProcedure procedure) { this.ParentElement = parent; this.Name = name; this.ProcedureName = referenceName; this.ProcedureReference = procedure; }
public static object CallDebug(this IFileProcedure procedure, params object[] args) { return(DoDynamicInvoke(procedure, true, args)); }
public void ReportError(IFileProcedure procedure, int line, ErrorID error, string description, Exception exception) { this.Errors.Add(new Tuple <IFileProcedure, int, ErrorID, string, Exception>(procedure, line, error, description, exception)); }