/// <summary> /// Creates a state. /// </summary> /// <param name="name">The name of the state.</param> /// <param name="parentRegion">The parent region of the state.</param> /// <param name="entryAction">The actions to be performed upon entry to the state.</param> /// <param name="exitAction">The actions to be performed upon exit of the state.</param> public NSFState(NSFString name, NSFRegion parentRegion, NSFVoidAction<NSFStateMachineContext> entryAction, NSFVoidAction<NSFStateMachineContext> exitAction) : base(name) { this.parentRegion = parentRegion; EntryActions += entryAction; ExitActions += exitAction; if (parentRegion != null) { parentRegion.addSubstate(this); } EntryActions.setExceptionAction(handleEntryActionException); ExitActions.setExceptionAction(handleExitActionException); }
/// <summary> /// Creates a transition. /// </summary> /// <param name="name">User assigned name for transition.</param> /// <param name="source">Transition source.</param> /// <param name="target">Transition target.</param> /// <param name="trigger">Transition trigger.</param> /// <param name="guard">Transition guard.</param> /// <param name="action">Transition action.</param> /// <remarks>Deprecated - Use NSFExternalTransition or NSFLocalTransition</remarks> protected NSFTransition(NSFString name, NSFState source, NSFState target, NSFEvent trigger, NSFBoolGuard<NSFStateMachineContext> guard, NSFVoidAction<NSFStateMachineContext> action) : base(name) { this.source = source; this.target = target; Guards += guard; Actions += action; addTrigger(trigger); // Validity check if ((source == target) && (triggers.Count == 0) && Guards.isEmpty()) { throw new Exception(Name + " invalid self-transition with no trigger or guard"); } target.addIncomingTransition(this); // Outgoing transitions must be added by concrete classes Guards.setExceptionAction(handleGuardException); Actions.setExceptionAction(handleActionException); }