public bool Execute() { if (Decision.ConditionsAreMet()) { if (Decision is IDisposable) { (Decision as IDisposable).Dispose(); } #if DEBUG && PC System.Console.WriteLine(); System.Console.WriteLine(Decision.ToString()); #endif for (int i = 0; i < _actions.Count; i++) { IScriptAction action = _actions[i]; action.Execute(); #if DEBUG && PC System.Console.WriteLine(action.ToString()); #endif } #if DEBUG && PC System.Console.WriteLine(); #endif return(true); } return(false); }
/// <summary> /// Executes the given action. /// </summary> /// <param name="action">The action.</param> /// <param name="addToList">if set to <c>true</c> the action will be added to the action list afterwards.</param> private void _ExecuteAction(IScriptAction action, bool addToList) { Contract.Requires(action != null); action.SourceImage = this.SourceImage; action.TargetImage = this.TargetImage; this.IsSourceImageChanged = false; this.IsTargetImageChanged = false; var result = action.Execute(); // execution of action failed Contract.Assert(result, "action failed somehow"); if (addToList) { this.AddWithoutExecution(action); } if (action.ChangesSourceImage) { this.SourceImage = action.SourceImage; this.IsSourceImageChanged = true; } if (action.ChangesTargetImage) { this.TargetImage = action.TargetImage; this.IsTargetImageChanged = true; } if (action.ProvidesNewGdiSource) { this._gdiSource = action.GdiSource; } }
/// <summary> /// Execute script action /// </summary> /// <param name="action">action to execute</param> /// <param name="args">list of parameters, in case the action is Call</param> /// <param name="isolation">isolation</param> /// <returns>action result</returns> public object ExecuteAction(IScriptAction action, IEnumerable <CallParam> args, CallIsolation isolation) { Vars snapshot = null; if (isolation != CallIsolation.None) { snapshot = new Vars(this); } try { // Clear vars if (isolation == CallIsolation.High) { base.Clear(); } return(RunOnStack(ScriptOperation.Executing, action, delegate { Sub sub = action as Sub; if (sub != null) { return sub.ExecuteSub(args); } return action.Execute(); })); } finally { if (snapshot != null) { base.Clear(); AddRange(snapshot); } } }
/// <summary> /// Executes the given action. /// </summary> /// <param name="action">The action.</param> /// <param name="addToList">if set to <c>true</c> the action will be added to the action list afterwards.</param> private void _ExecuteAction(IScriptAction action, bool addToList) { Contract.Requires(action != null); action.SourceImage = this.SourceImage; action.TargetImage = this.TargetImage; this.IsSourceImageChanged = false; this.IsTargetImageChanged = false; var result = action.Execute(); // execution of action failed Contract.Assert(result, "action failed somehow"); if (addToList) this.AddWithoutExecution(action); if (action.ChangesSourceImage) { this.SourceImage = action.SourceImage; this.IsSourceImageChanged = true; } if (action.ChangesTargetImage) { this.TargetImage = action.TargetImage; this.IsTargetImageChanged = true; } if (action.ProvidesNewGdiSource) this._gdiSource = action.GdiSource; }
public virtual object Execute(IScriptAction action) { return(action != null?RunOnStack(ScriptOperation.Executing, action, () => action.Execute()) : null); }