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

            _eventHandlers = new Dictionary <TState, List <IStateEventHandler> >(_stateComparer);
            _stateHierarchyBehaviourScheduler = stateHierarchyBehaviourScheduler;
        }
Esempio n. 2
0
        public HierarchicalStateMachine(IEqualityComparer <TState> stateComparer, IEqualityComparer <TTrigger> triggerComparer)
        {
            if (stateComparer == null)
            {
                throw new ArgumentNullException(nameof(stateComparer));
            }
            if (triggerComparer == null)
            {
                throw new ArgumentNullException(nameof(triggerComparer));
            }

            _stateComparer   = new Comparer <TState>();
            _triggerComparer = new Comparer <TTrigger>();

            SetStateComparer(stateComparer);
            SetTriggerComparer(triggerComparer);

            _stateHierarchy = new StateHierarchy <TState>(_stateComparer);
            _stateHierarchyBehaviourScheduler = new StateHierarchyBehaviourScheduler <TState>(_stateHierarchy, _stateComparer);
            _transitionValidator         = new TransitionValidator <TState, TTrigger>(_stateComparer, _triggerComparer, _stateHierarchyBehaviourScheduler);
            _transitionHandler           = new TransitionHandler <TState, TTrigger>(_stateComparer, _triggerComparer, _stateHierarchyBehaviourScheduler, _transitionValidator);
            _hierarchicalEventDispatcher = new HierarchicalEventDispatcher <TState>(_stateComparer, _stateHierarchyBehaviourScheduler);

            SubscribeToEventsForInternalStateChanging();
            SubscribeToHierarchyPathChangeEvents();
            SubscribeToEventsForSavingValidTransition();
        }
Esempio n. 3
0
        public HierarchicalEventDispatcher(IEqualityComparer <TState> stateComparer,
                                           HierarchicalStateEventHandlerCollection <TState, TTrigger> eventHandlers,
                                           StateHierarchyBehaviourScheduler <TState, TTrigger> stateHierarchyBehaviourScheduler)
        {
            _stateComparer = stateComparer ?? throw new ArgumentNullException(nameof(stateComparer));

            _eventHandlers = eventHandlers;
            _stateHierarchyBehaviourScheduler = stateHierarchyBehaviourScheduler;
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public HierarchicalTransitionValidator(IEqualityComparer <TState> stateComparer, IEqualityComparer <Transition <TState, TTrigger> > transitionEqualityComparer,
                                               StateHierarchyBehaviourScheduler <TState, TTrigger> stateHierarchyBehaviourScheduler,
                                               StateHierarchy <TState, TTrigger> stateHierarchy)
        {
            _stateHierarchyBehaviourScheduler = stateHierarchyBehaviourScheduler;
            _stateHierarchy             = stateHierarchy;
            _stateComparer              = stateComparer;
            _transitionEqualityComparer = transitionEqualityComparer;

            _guardConditions = new Dictionary <Transition <TState, TTrigger>, List <IGuardCondition> >(_transitionEqualityComparer);
        }
        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. 7
0
        public HierarchicalStateMachine(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);

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

            _stateHierarchy = new StateHierarchy <TState, TTrigger>(this, _stateComparer);
            _stateHierarchyBehaviourScheduler = new StateHierarchyBehaviourScheduler <TState, TTrigger>(this, _stateHierarchy, _transitions, _transitionValidator, _stateComparer, _triggerComparer);
            _transitionValidator = new HierarchicalTransitionValidator <TState, TTrigger>(_stateComparer, _transitionComparer, _stateHierarchyBehaviourScheduler, _stateHierarchy);
            _transitions         = new HierarchicalTransitionCollection <TState, TTrigger>(this, _stateComparer, _transitionComparer);
            _eventHandlers       = new HierarchicalStateEventHandlerCollection <TState, TTrigger>(this, _stateComparer);
            _eventDispatcher     = new HierarchicalEventDispatcher <TState, TTrigger>(_stateComparer, _eventHandlers, _stateHierarchyBehaviourScheduler);
        }