Esempio n. 1
0
        public void Execute(TInstance instance)
        {
            while (true)
            {
                try
                {
                    _activities.Execute(instance);
                    return;
                }
                catch (Exception ex)
                {
                    try
                    {
                        ExceptionHandlerResult result = _exceptionHandler.Handle(instance, _event, ex);
                        if (result == ExceptionHandlerResult.Unhandled)
                        {
                            throw;
                        }

                        if (result == ExceptionHandlerResult.Return)
                        {
                            return;
                        }
                    }
                    catch (Exception innerException)
                    {
                        string message = "{0} occurred while handling {1} during {2}"
                                         .FormatWith(innerException.GetType().ToShortTypeName(), _event.Name, _state.Name);

                        throw new StateMachineWorkflowException(message, innerException);
                    }
                }
            }
        }
Esempio n. 2
0
        public void Execute <T>(TInstance instance, T bodyT)
        {
            if (typeof(TBody) != typeof(T))
            {
                throw new StateMachineWorkflowException("Body type mismatch for message event: " + Event.Name);
            }

            var body = (TBody)((object)bodyT);

            while (true)
            {
                try
                {
                    _activities.Execute(instance, body);
                    return;
                }
                catch (Exception ex)
                {
                    try
                    {
                        ExceptionHandlerResult result = _exceptionHandler.Handle(instance, _event, body, ex);
                        if (result == ExceptionHandlerResult.Unhandled)
                        {
                            throw;
                        }

                        if (result == ExceptionHandlerResult.Return)
                        {
                            return;
                        }
                    }
                    catch (Exception innerException)
                    {
                        string message = "{0} occurred while handling {1} during {2}"
                                         .FormatWith(innerException.GetType().ToShortTypeName(), _event.Name, _state.Name);

                        throw new StateMachineWorkflowException(message, innerException);
                    }
                }
            }
        }
Esempio n. 3
0
 public ExceptionHandlerResult Handle(TInstance instance, Event eevent, TBody body, Exception exception)
 {
     return(_handler.Handle(instance, eevent, exception));
 }