12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #region --------------- Copyright Dresser Wayne Pignone -------------
- /*
- * $Log: /Wrk/WayneLibraries/Wrk/StateEngine/ExplicitTransition.cs $
- *
- * 2 08-02-26 14:07 Mattias.larsson
- * Renamed TargetStateName to TargetStateFactoryName.
- */
- #endregion
- #region Old file header
- /*===============================================================================
- * CompositeState
- *
- * Change history
- * When Who Comment
- * ---------- ------ ------------------------------------
- * 2006-01-09 RMa Added comments
- * 2006-01-05 RMa Created
- *
- ---------------------------------------------------------------------------------*/
- #endregion
- namespace Wayne.Lib.StateEngine
- {
- /// <summary>
- /// The Explicit transition is a way to go around the State Transition Lookup, and directly
- /// decide which state to go to.
- /// It can be used in a small state machine application when an soft-coded state-transition
- /// configuration not is neccecary.
- /// Another usage is when doing transitions to general states like an error state. When we
- /// want to return from that state, we want to return to the state where it came from.
- ///
- /// </summary>
- /// <example>
- /// <code>
- /// Example of how to use the Explicit state as a "back" transition.
- ///
- /// class ErrorState : Wayne.Lib.StateEngine.State
- /// {
- /// string cameFromState;
- ///
- /// public override void Enter(Wayne.Lib.StateEngine.StateEntry Entry)
- /// {
- /// cameFromState = Entry.SourceTransition.Sender.Name;
- ///
- /// //Do some error handling code
- /// }
- ///
- /// public override void HandleEvent(Wayne.Lib.StateEngine.Event EventToHandle)
- /// {
- /// if (EventToHandle is ErrorConfirmedEvent) //The appropriate event has arrived, so we can leave the state.
- /// {
- /// PostTransition(new Wayne.Lib.StateEngine.ExplicitTransition(this, Wayne.Lib.StateEngine.BasicTransitionTypes.Done, cameFromState));
- /// }
- /// }
- /// }
- /// </code>
- /// </example>
- public class ExplicitTransition : Transition
- {
- #region Fields
- private string targetStateFactoryName;
- #endregion
- /// <summary>
- /// Constructor for the explicit transaction
- /// </summary>
- /// <param name="sender">State object that issued the transition</param>
- /// <param name="transitionType">Object representing the type of the transition</param>
- /// <param name="targetStateFactoryName">FactoryName of the state that should be searched for and entered.</param>
- public ExplicitTransition(State sender, object transitionType, string targetStateFactoryName)
- : base(sender, transitionType)
- {
- this.targetStateFactoryName = targetStateFactoryName;
- }
- /// <summary>
- /// Name of the target state of the transition.
- /// </summary>
- public string TargetStateFactoryName
- {
- get { return targetStateFactoryName; }
- }
- }
- }
|