public IExecutionStep Execute(IFreeformEntity_Msg request) { using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "ProcessMessage")) { try { ExecutionStep step = null; this.ExecutionResult = ExecutionStepResult.None; ExecutionStepKeyValue pair = new ExecutionStepKeyValue(request.EntityUniqueKeyString, request.FlowDirection); string uniqueKey = pair.FullKey; // current execution step if (this.CanExecute(pair, request)) { step = this; } // next step is responsible else if (_nextStep != null && _nextStep.CanExecute(pair, request)) { step = _nextStep as ExecutionStep; } // any of the next steps is responsible else if (_hasNextSteps) { if (_nextStepsCached.ContainsKey(uniqueKey)) { step = _nextStepsCached[uniqueKey]; } else { foreach (var nextStep in this.NextSteps) { if (nextStep.CanExecute(pair, request)) { step = nextStep as ExecutionStep; _nextStepsCached.Add(uniqueKey, step); break; } } } } // any thing is responsible? if (step != null) { return(step.ExecuteInternal(method, request)); } } catch (Exception ex) { method.Exception(ex); } return(null); } }