/// <summary> /// Called when the state is entered. /// </summary> /// <param name="onEnter">When the state is entered.</param> /// <returns>The state builder.</returns> public IStateBuilder <TState, TTransition, TPayload> OnStateEnter(StateMachineDelegates.StateMachineEnterDel <TState, TTransition, TPayload> onEnter) { if (null != this.OnEnter) { throw new ArgumentException("Cannot set the OnEnter method twice"); } this.OnEnter = onEnter; return(this); }
/// <summary> /// Initializes a new instance of the <see cref="StateMachineState{TState, TTransition, TPayload}"/> class. /// </summary> /// <param name="state">The state.</param> /// <param name="stateMachine">The state machine.</param> /// <param name="onEnter">The on enter method.</param> /// <param name="faultHandler">The fault handler.</param> public StateMachineState( TState state, StateMachineBase <TState, TTransition, TPayload> stateMachine, StateMachineDelegates.StateMachineEnterDel <TState, TTransition, TPayload> onEnter, Action <StateMachineContextBase <TState, TTransition, TPayload>, Exception> faultHandler) { this.State = state; this.stateMachine = stateMachine; this.transitions = new Dictionary <TTransition, StateMachineTransition <TState, TTransition, TPayload> >(); this.OnEnter = onEnter; this.faultHandler = faultHandler; }