示例#1
0
        /// <summary>
        /// Transition to a given state
        /// </summary>
        /// <param name="newState"><see cref="State"/> to transition to</param>
        /// <exception cref="InvalidSagaStateTransitionException">Thrown if transition is not allowed</exception>
        public void TransitionTo(State newState)
        {
            if(!CanTransitionTo(newState))
                throw new InvalidSagaStateTransitionException(string.Format("Cannot transition from State [{0}] to State [{1}]",_currentState.GetType().FullName, newState.GetType().FullName));

            _currentState = newState;
        }
示例#2
0
文件: State.cs 项目: JoB70/Bifrost
 /// <summary>
 /// Check if this state can transition to a specified state
 /// </summary>
 /// <param name="state"><see cref="State"/> to check if can transition to</param>
 /// <returns>true if it can transition, false if not</returns>
 public bool CanTransitionTo(State state)
 {
     return _canTransitionTo.Contains(state);
 }
示例#3
0
 /// <summary>
 /// Check if a transition is allowed
 /// </summary>
 /// <param name="newState"><see cref="State"/> to check if is allowed</param>
 /// <returns>true if transition is allowed, false if not</returns>
 public bool CanTransitionTo(State newState)
 {
     return _currentState.CanTransitionTo(newState);
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of <see cref="SagaState"/> with a current state
 /// </summary>
 /// <param name="currentState"><see cref="State">Current state</see> to set</param>
 public SagaState(State currentState)
 {
     _currentState = currentState;
 }