private void TraverseDownTheStateHierarchyAndEnterStates(
     IStateLogic <TState, TEvent> stateLogic,
     Stack <IStateDefinition <TState, TEvent> > stack)
 {
     while (stack.Count > 0)
     {
         var state = stack.Pop();
         stateLogic.Entry(state, this.context);
     }
 }
        public TState EnterInitialState(
            IStateLogic <TState, TEvent> stateLogic,
            ILastActiveStateModifier <TState, TEvent> lastActiveStateModifier)
        {
            var stack = this.TraverseUpTheStateHierarchy();

            this.TraverseDownTheStateHierarchyAndEnterStates(stateLogic, stack);

            return(stateLogic.EnterByHistory(this.initialState, this.context, lastActiveStateModifier));
        }
 private async Task TraverseDownTheStateHierarchyAndEnterStates(
     IStateLogic <TState, TEvent> stateLogic,
     Stack <IStateDefinition <TState, TEvent> > stack)
 {
     while (stack.Count > 0)
     {
         var state = stack.Pop();
         await stateLogic.Entry(state, this.context)
         .ConfigureAwait(false);
     }
 }
Example #4
0
        public async Task <TState> EnterInitialState(
            IStateLogic <TState, TEvent> stateLogic,
            ILastActiveStateModifier <TState, TEvent> lastActiveStateModifier)
        {
            var stack = this.TraverseUpTheStateHierarchy();

            await this.TraverseDownTheStateHierarchyAndEnterStates(stateLogic, stack)
            .ConfigureAwait(false);

            return(await stateLogic.EnterByHistory(this.initialState, this.context, lastActiveStateModifier)
                   .ConfigureAwait(false));
        }
        public void Initialize(IAppContext context, IDataRepository dataRepository)
        {
            _context            = context;
            _versionResult      = dataRepository.GetContainer <VersionResult>(DataKey.VersionResult);
            _pLoginResult       = dataRepository.GetContainer <PLoginResult>(DataKey.PLoginResult);
            _billboardRead      = dataRepository.GetContainer <bool>(DataKey.BillboardRead);
            _hServerAddressUser = dataRepository.GetContainer <string>(DataKey.HServerAddress);

            _stateLogic = new StateLogic <IAppContext>("TestLoginStateMachine", context);
            _stateLogic.AddState(new TestBuildFirstAssetBundleState());
            _stateLogic.AddState(new SetPServerState());
            _stateLogic.AddState(new ConnetPserverState());
            _stateLogic.AddState(new SetClientVersionState());
            _stateLogic.AddState(new GetClientVersionState());
            _stateLogic.AddState(new SelectLoginTypeSate());
            _stateLogic.AddState(new LoginPServerState());
        }
Example #6
0
        public void Initialize(IAppContext context, IDataRepository dataRepository)
        {
            _context        = context;
            _versionResult  = dataRepository.GetContainer <VersionResult>(DataKey.VersionResult);
            _pLoginResult   = dataRepository.GetContainer <PLoginResult>(DataKey.PLoginResult);
            _billboardRead  = dataRepository.GetContainer <bool>(DataKey.BillboardRead);
            _hServerAddress = dataRepository.GetContainer <string>(DataKey.HServerAddress);
            _gServerAddress = dataRepository.GetContainer <ServerAddress>(DataKey.GameServerAddress);

            _stateLogic = new StateLogic <IAppContext>("LoginStateMachine", context);
            _stateLogic.AddState(new NetworkPIPState());
            _stateLogic.AddState(new NetworkBuildFirstCacheState());
            _stateLogic.AddState(new NetworkDownloadResourcesState());
            _stateLogic.AddState(new NetworkConnectGateServerState());
            _stateLogic.AddState(new NetworkClientVersionState());
            _stateLogic.AddState(new NetworkLoginTypeState());
            _stateLogic.AddState(new NetworkLoginGateServerState());
            _stateLogic.AddState(new NetworkConnectHallServerState());
            _stateLogic.AddState(new NetworkLoginHallServerState());
            _stateLogic.AddState(new NetworkLoginHallServerOkState());
            _stateLogic.AddState(new NetworkConnectGameServerState());
            _stateLogic.AddState(new NetworkLoginGameServerState());
            _stateLogic.AddState(new NetworkLoginGameServerOkState());
        }
 public void SetStateLogic(IStateLogic <TState, TEvent> stateLogicToSet)
 {
     this.stateLogic = stateLogicToSet;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StateMachine{TState,TEvent}"/> class.
 /// </summary>
 /// <param name="factory">The factory used to create internal instances.</param>
 /// <param name="stateLogic">The state logic used to handle state changes.</param>
 public StateMachine(IFactory <TState, TEvent> factory, IStateLogic <TState, TEvent> stateLogic)
 {
     this.factory    = factory;
     this.stateLogic = stateLogic;
 }
Example #9
0
 public StateController(IStateLogic stateLogic)
 {
     _stateLogic = stateLogic;
 }