public StateMachine <TState, TEvent> Build() { var factory = new StandardFactory <TState, TEvent>(); var transitionLogic = new TransitionLogic <TState, TEvent>(this.stateContainer, this.stateContainer); var stateLogic = new StateLogic <TState, TEvent>(transitionLogic, this.stateContainer, this.stateContainer); transitionLogic.SetStateLogic(stateLogic); return(new StateMachine <TState, TEvent>(factory, stateLogic)); }
public ActiveStateMachine <TState, TEvent> CreateActiveStateMachine(string name) { var stateContainer = new StateContainer <TState, TEvent>(name); foreach (var stateIdAndLastActiveState in this.initiallyLastActiveStates) { stateContainer.SetLastActiveStateFor(stateIdAndLastActiveState.Key, stateIdAndLastActiveState.Value); } var transitionLogic = new TransitionLogic <TState, TEvent>(stateContainer, stateContainer); var stateLogic = new StateLogic <TState, TEvent>(transitionLogic, stateContainer, stateContainer); transitionLogic.SetStateLogic(stateLogic); var standardFactory = new StandardFactory <TState, TEvent>(); var stateMachine = new StateMachine <TState, TEvent>(standardFactory, stateLogic); return(new ActiveStateMachine <TState, TEvent>(stateMachine, stateContainer, this.stateDefinitions, this.initialState)); }