/// <summary> /// Selects an event that is accepted during the specified state /// </summary> /// <typeparam name="TWorkflow"></typeparam> /// <typeparam name="TInstance"></typeparam> /// <param name="stateConfigurator"></param> /// <param name="eventExpression"></param> /// <returns></returns> public static ActivityConfigurator <TWorkflow, TInstance> When <TWorkflow, TInstance>( this StateConfigurator <TWorkflow, TInstance> stateConfigurator, Expression <Func <TWorkflow, Event> > eventExpression) where TWorkflow : class where TInstance : class { return(stateConfigurator.When(eventExpression, DoNothing)); }
public static ActivityConfigurator <IServiceWorkflow, IServiceController, RestartService> AcceptRestart( this StateConfigurator <IServiceWorkflow, IServiceController> configurator) { return(configurator .When(e => e.Restart) .TransitionTo(s => s.StoppingToRestart) .Then(i => i.Stop)); }
public static ActivityConfigurator <IServiceWorkflow, IServiceController, ServiceFault> AcceptFault( this StateConfigurator <IServiceWorkflow, IServiceController> configurator) { return(configurator .When(e => e.OnFaulted) .LogFault() .TransitionTo(s => s.Faulted)); }
public static ActivityConfigurator <IServiceWorkflow, IServiceController, PauseService> AcceptPause( this StateConfigurator <IServiceWorkflow, IServiceController> configurator) { return(configurator .When(e => e.Pause) .TransitionTo(s => s.Pausing) .Then(i => i.Pause)); }
public MessageActivityConfigurator(StateConfigurator <TWorkflow, TInstance> stateConfigurator, Expression <Func <TWorkflow, Event <TBody> > > eventExpression) { _stateConfigurator = stateConfigurator; _eventExpression = eventExpression; _configurators = new List <ActivityBuilderConfigurator <TWorkflow, TInstance, TBody> >(); }
/// <summary> /// Creates a state with a sub-machine in it /// </summary> /// <param name="stateName">The name of the state</param> /// <param name="subStateMachine">The sub-state machine that the state has</param> /// <param name="entryState">The entry state of the submachine</param> /// <param name="stateMachineB">The state machine which the state belongs to</param> public State(string stateName, State entrySubMachineState, State stateTo, BehaviourEngine subMachine, BehaviourEngine behaviourEngine) { this.Name = stateName; this.BehaviourEngine = behaviourEngine; this.configurator = new StateConfigurator(StateConfigurator.STATE_TYPE.NOT_EMPTY); BehaviourEngine.Configure(this) .OnEntry(() => EntrySubmachine(entrySubMachineState, stateTo, subMachine, behaviourEngine)); }
/// <summary> /// State that runs a method with no parameters /// </summary> /// <param name="stateName">Name of the state</param> /// <param name="method">Method with no parameters. MUST be a void method</param> /// <param name="behaviourEngine">The machine which the state belongs to</param> public State(string stateName, Action method, BehaviourEngine behaviourEngine) { this.Name = stateName; this.StateActionVoid = method; this.BehaviourEngine = behaviourEngine; this.configurator = new StateConfigurator(StateConfigurator.STATE_TYPE.NOT_EMPTY); BehaviourEngine.Configure(this) .OnEntry(() => method()); }
/// <summary> /// State that runs a method with a <see cref="Perception"/> parameter /// </summary> /// <param name="stateName">Name of the state</param> /// <param name="method">Method with no parameters. MUST be a void method</param> /// <param name="behaviourEngine">The machine which the state belongs to</param> public State(string stateName, Action <Perception> method, BehaviourEngine behaviourEngine) { this.Name = stateName; this.StateActionPerception = method; this.StatePerception = (Perception)method.Method.GetParameters().GetValue(0); this.BehaviourEngine = behaviourEngine; this.configurator = new StateConfigurator(StateConfigurator.STATE_TYPE.NOT_EMPTY); BehaviourEngine.Configure(this) .OnEntry(() => method((Perception)method.Method.GetParameters().GetValue(0))); }
public static ActivityConfigurator <TWorkflow, TInstance> When <TWorkflow, TInstance>( this StateConfigurator <TWorkflow, TInstance> stateConfigurator, Expression <Func <TWorkflow, Event> > eventExpression, Action <ActivityConfigurator <TWorkflow, TInstance> > configurationAction) where TWorkflow : class where TInstance : class { var configurator = new SimpleActivityConfigurator <TWorkflow, TInstance>(stateConfigurator, eventExpression); stateConfigurator.AddConfigurator(configurator); configurationAction(configurator); return(configurator); }
SimpleActivityConfigurator(StateConfigurator <TWorkflow, TInstance> stateConfigurator) { _stateConfigurator = stateConfigurator; _configurators = new List <ActivityBuilderConfigurator <TWorkflow, TInstance> >(); }
public SimpleActivityConfigurator(StateConfigurator <TWorkflow, TInstance> stateConfigurator, string eventName) : this(stateConfigurator) { _getEvent = builder => builder.Model.GetEvent(eventName); }
public SimpleActivityConfigurator(StateConfigurator <TWorkflow, TInstance> stateConfigurator, Expression <Func <TWorkflow, Event> > eventExpression) : this(stateConfigurator) { _getEvent = builder => builder.Model.GetEvent(eventExpression); }
/// <summary> /// Empty state /// </summary> /// <param name="stateName">The name of the state</param> /// <param name="behaviourEngine">The machine which the state belongs to</param> public State(string stateName, BehaviourEngine behaviourEngine) { this.Name = stateName; this.BehaviourEngine = behaviourEngine; this.configurator = new StateConfigurator(StateConfigurator.STATE_TYPE.EMPTY); }