Esempio n. 1
0
        public TransitionValidator(IEqualityComparer <TState> stateComparer, IEqualityComparer <TTrigger> triggerComparer,
                                   StateHierarchyBehaviourScheduler <TState> stateHierarchyBehaviourScheduler)
        {
            _stateComparer   = stateComparer ?? throw new ArgumentNullException(nameof(stateComparer));
            _triggerComparer = triggerComparer ?? throw new ArgumentNullException(nameof(triggerComparer));
            _stateHierarchyBehaviourScheduler = stateHierarchyBehaviourScheduler;

            _transitionComparer = new TransitionEqualityComparer <TState, TTrigger>(_stateComparer, _triggerComparer);

            _guardConditions = new Dictionary <Transition <TState, TTrigger>, List <IGuardCondition> >(_transitionComparer);
        }
        public TransitionHandler(IEqualityComparer <TState> stateComparer, IEqualityComparer <TTrigger> triggerComparer,
                                 StateHierarchyBehaviourScheduler <TState> stateHierarchyBehaviourScheduler, ITransitionValidator <TState, TTrigger> transitionValidator)
        {
            _stateComparer              = stateComparer;
            _triggerComparer            = triggerComparer;
            _transitionEqualityComparer = new TransitionEqualityComparer <TState, TTrigger>(_stateComparer, _triggerComparer);

            _stateHierarchyBehaviourScheduler = stateHierarchyBehaviourScheduler;
            _transitionValidator = transitionValidator;
            _transitions         = new HashSet <Transition <TState, TTrigger> >(_transitionEqualityComparer);
            _pendingTriggers     = new Queue <TTrigger>();
        }
Esempio n. 3
0
        public PlainStateMachine(IEqualityComparer <TState> stateComparer, IEqualityComparer <TTrigger> triggerComparer)
        {
            if (stateComparer == null)
            {
                throw new ArgumentNullException(nameof(stateComparer));
            }
            if (triggerComparer == null)
            {
                throw new ArgumentNullException(nameof(triggerComparer));
            }

            _stateComparer   = new StateEqualityComparer(stateComparer);
            _triggerComparer = new TriggerEqualityComparer(triggerComparer);

            _transitionEqualityComparer = new TransitionEqualityComparer(_stateComparer, _triggerComparer);

            _states                 = new Dictionary <TState, IState>(_stateComparer);
            _transitions            = new HashSet <Transition <TState, TTrigger> >(_transitionEqualityComparer);
            _guardConditions        = new Dictionary <Transition <TState, TTrigger>, List <IGuardCondition> >(_transitionEqualityComparer);
            _stateEventHandlers     = new Dictionary <TState, HashSet <IStateEventHandler> >(_stateComparer);
            _transitionCommandQueue = new Queue <TransitionCommand>();
        }