Ejemplo n.º 1
0
 private void EnforceNotIdentityTransition(TStateType destination)
 {
     if (destination.Equals(_specification.UnderlyingState))
     {
         throw new ArgumentException("Cannot transition to same state.");
     }
 }
Ejemplo n.º 2
0
 private StateSpecifier InternalPermitIf(TTriggerType trigger, TStateType destinationState,
                                         Func <bool> triggerCondition)
 {
     _specification.AddTriggerStrategy(new StateTransitionTriggerStrategy(trigger, destinationState,
                                                                          triggerCondition));
     return(this);
 }
Ejemplo n.º 3
0
            public StateSpecifier SubstateOf(TStateType superstate)
            {
                var superRepresentation = _specificationLookup(superstate);

                _specification.Superstate = superRepresentation;
                superRepresentation.AddSubstate(_specification);
                return(this);
            }
 public override bool ResultsInTransitionFrom(TStateType source, object[] args, out TStateType destination)
 {
     destination = _destination(args);
     return(true);
 }
Ejemplo n.º 5
0
 public State(FSM <TStateType> fsm, TStateType stateType)
 {
     _fsm      = fsm;
     StateType = stateType;
 }
Ejemplo n.º 6
0
 public StateTransition(TStateType source, TStateType destination, TTriggerType trigger)
 {
     _source      = source;
     _destination = destination;
     _trigger     = trigger;
 }
Ejemplo n.º 7
0
 public abstract bool ResultsInTransitionFrom(TStateType source, object[] args, out TStateType destination);
Ejemplo n.º 8
0
 public StateSpecifier PermitIf(TTriggerType trigger, TStateType destinationState,
                                Func <bool> triggerCondition)
 {
     EnforceNotIdentityTransition(destinationState);
     return(InternalPermitIf(trigger, destinationState, triggerCondition));
 }
Ejemplo n.º 9
0
 public StateSpecifier Permit(TTriggerType trigger, TStateType destinationState)
 {
     EnforceNotIdentityTransition(destinationState);
     return(InternalPermit(trigger, destinationState));
 }
Ejemplo n.º 10
0
 private StateSpecifier InternalPermit(TTriggerType trigger, TStateType destinationState)
 {
     return(InternalPermitIf(trigger, destinationState, () => true));
 }
Ejemplo n.º 11
0
 public override bool ResultsInTransitionFrom(TStateType source, object[] args, out TStateType destination)
 {
     destination = default(TStateType);
     return(false);
 }
Ejemplo n.º 12
0
 public StateTransitionTriggerStrategy(TTriggerType trigger, TStateType destination,
                                       Func <bool> triggerCondition)
     : base(trigger, triggerCondition)
 {
     _destination = destination;
 }
Ejemplo n.º 13
0
 public StateSpecification(TStateType state)
 {
     _state = state;
 }
Ejemplo n.º 14
0
 public bool IsIncludedIn(TStateType state)
 {
     return
         (_state.Equals(state) ||
          (_superstate != null && _superstate.IsIncludedIn(state)));
 }
Ejemplo n.º 15
0
 public bool Includes(TStateType state)
 {
     return(_state.Equals(state) || _substates.Any(s => s.Includes(state)));
 }