/// <summary>
 /// Ignore the specified trigger when in the configured state, if the guard
 /// returns true..
 /// </summary>
 /// <param name="trigger">The trigger to ignore.</param>
 /// <param name="guardDescription">Guard description</param>
 /// <param name="guard">Function that must return true in order for the
 /// trigger to be ignored.</param>
 /// <returns>The receiver.</returns>
 public StateConfiguration IgnoreIf(TTrigger trigger, Func <bool> guard, string guardDescription = null)
 {
     Enforce.ArgumentNotNull(guard, nameof(guard));
     _representation.AddTriggerBehaviour(
         new IgnoredTriggerBehaviour(
             trigger,
             guard,
             guardDescription != null ? guardDescription : guard?.Method.Name));
     return(this);
 }
Beispiel #2
0
 public StateConfiguration Permit(TTrigger trigger, TState destinationState, Func <TState, TTrigger, bool> action)
 {
     if (!_representation.TriggerBehaviours.ContainsKey(trigger))
     {
         StateRepresentation sr = _machine.GetRepresentation(_machine._nullState);
         sr.AddTriggerBehaviour(new TransitioningTriggerBehaviour(trigger, destinationState, action));
     }
     _representation.AddTriggerBehaviour(new TransitioningTriggerBehaviour(trigger, destinationState, action));
     return(this);
 }
Beispiel #3
0
            /// <summary>
            /// Add an internal transition to the state machine. An internal action does not cause the Exit and Entry actions to be triggered, and does not change the state of the state machine
            /// </summary>
            /// <param name="trigger"></param>
            /// <param name="entryAction"></param>
            /// <returns></returns>
            public StateConfiguration InternalTransition(TTrigger trigger, Action <Transition> entryAction)
            {
                if (entryAction == null)
                {
                    throw new ArgumentNullException(nameof(entryAction));
                }

                _representation.AddTriggerBehaviour(new InternalTriggerBehaviour(trigger));
                _representation.AddInternalAction(trigger, (t, args) => entryAction(t));
                return(this);
            }
 /// <summary>
 ///
 /// </summary>
 /// <param name="trigger"></param>
 /// <param name="entryAction"></param>
 /// <returns></returns>
 public StateConfiguration InternalTransition(TTrigger trigger, Action <Transition> entryAction)
 {
     _representation.AddTriggerBehaviour(new InternalTriggerBehaviour(trigger));
     _representation.AddInternalAction(trigger, (t, args) => entryAction(t));
     return(this);
 }
 /// <summary>
 /// Ignore the specified trigger when in the configured state, if the guard
 /// returns true..
 /// </summary>
 /// <param name="trigger">The trigger to ignore.</param>
 /// <param name="guard">Function that must return true in order for the
 /// trigger to be ignored.</param>
 /// <returns>The receiver.</returns>
 public StateConfiguration IgnoreIf(TTrigger trigger, Func <bool> guard)
 {
     Enforce.ArgumentNotNull(guard, "guard");
     m_representation.AddTriggerBehaviour(new IgnoredTriggerBehaviour(trigger, guard));
     return(this);
 }
Beispiel #6
0
 private StateConfiguration InternalPermitIf(TTrigger trigger, TState destinationState, Func <bool> guard)
 {
     mRepresentation.AddTriggerBehaviour(new TransitioningTriggerBehaviour(trigger, destinationState, guard));
     return(this);
 }