#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
using System;
using System.Collections.Generic;
using System.Text;
namespace Wayne.Lib.StateEngine
{
///
/// 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.
///
///
///
///
/// 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));
/// }
/// }
/// }
///
///
public class ExplicitTransition : Transition
{
#region Fields
private string targetStateFactoryName;
#endregion
///
/// Constructor for the explicit transaction
///
/// State object that issued the transition
/// Object representing the type of the transition
/// FactoryName of the state that should be searched for and entered.
public ExplicitTransition(State sender, object transitionType, string targetStateFactoryName)
: base(sender, transitionType)
{
this.targetStateFactoryName = targetStateFactoryName;
}
///
/// Name of the target state of the transition.
///
public string TargetStateFactoryName
{
get { return targetStateFactoryName; }
}
}
}