public State <TS, TD, TE> Copy(TimeSpan?timeout, FSMBase.Reason stopReason = null, List <object> replies = null, ILinearSeq <TE> domainEvents = null, Action <TD> afterTransitionDo = null) { return(new State <TS, TD, TE>(StateName, StateData, timeout ?? Timeout, stopReason ?? StopReason, replies ?? Replies, domainEvents ?? DomainEvents, afterTransitionDo ?? AfterTransitionHandler)); }
public State(TS stateName, TD stateData, TimeSpan?timeout = null, FSMBase.Reason stopReason = null, List <object> replies = null, ILinearSeq <TE> domainEvents = null, Action <TD> afterTransitionDo = null) : base(stateName, stateData, timeout, stopReason, replies) { AfterTransitionHandler = afterTransitionDo; DomainEvents = domainEvents; Notifies = true; }
public State Copy( TimeSpan?timeout, FSMBase.Reason stopReason = null, List <object> replies = null, ILinearSeq <TEvent> domainEvents = null, Action <TData> afterTransitionDo = null) { return(_state.Copy(timeout, stopReason, replies, domainEvents, afterTransitionDo)); }
public State( TState stateName, TData stateData, TimeSpan?timeout = null, FSMBase.Reason stopReason = null, List <object> replies = null, ILinearSeq <TEvent> domainEvents = null, Action <TData> afterTransitionDo = null) { _state = new State(stateName, stateData, timeout, stopReason, replies, domainEvents, afterTransitionDo); }
/// <summary> /// By default, <see cref="Failure" /> is logged at error level and other /// reason types are not logged. It is possible to override this behavior. /// </summary> /// <param name="reason">TBD</param> protected virtual void LogTermination(FSMBase.Reason reason) { if (reason is FSMBase.Failure failure) { if (failure.Cause is Exception) { _log.Error(failure.Cause.AsInstanceOf <Exception>(), "terminating due to Failure"); } else { _log.Error(failure.Cause.ToString()); } } }
/// <summary> /// By default, <see cref="Failure" /> is logged at error level and other /// reason types are not logged. It is possible to override this behavior. /// </summary> /// <param name="reason"></param> protected virtual void LogTermination(FSMBase.Reason reason) { reason.Match() .With <FSMBase.Failure>(f => { if (f.Cause is Exception) { _log.Error(f.Cause.AsInstanceOf <Exception>(), "terminating due to Failure"); } else { _log.Error(f.Cause.ToString()); } }); }
/// <summary> /// Initializes a new instance of the <see cref="State{TS, TE, TD}"/> /// </summary> /// <param name="stateName">TBD</param> /// <param name="stateData">TBD</param> /// <param name="timeout">TBD</param> /// <param name="stopReason">TBD</param> /// <param name="replies">TBD</param> /// <param name="domainEvents">TBD</param> /// <param name="afterTransitionDo"></param> /// <param name="notifies">TBD</param> public State( TS stateName, TD stateData, TimeSpan?timeout = null, FSMBase.Reason stopReason = null, IReadOnlyList <object> replies = null, IReadOnlyList <TE> domainEvents = null, Action <TD> afterTransitionDo = null, bool notifies = true) { StateName = stateName; StateData = stateData; Timeout = timeout; StopReason = stopReason; AfterTransitionDo = afterTransitionDo; Replies = replies ?? new List <object>(); DomainEvents = domainEvents ?? new List <TE>(); Notifies = notifies; }
internal State <TS, TD, TE> Copy( TS stateName = default(TS), TD stateData = default(TD), TimeSpan?timeout = null, FSMBase.Reason stopReason = null, IReadOnlyList <object> replies = null, IReadOnlyList <TE> domainEvents = null, Action <TD> afterTransitionDo = null, bool?notifies = null) { return(new State <TS, TD, TE>( Equals(stateName, default(TS)) ? StateName : stateName, Equals(stateData, default(TD)) ? StateData : stateData, timeout == TimeSpan.MinValue ? null : timeout ?? Timeout, stopReason ?? StopReason, replies ?? Replies, domainEvents ?? DomainEvents, afterTransitionDo ?? AfterTransitionDo, notifies ?? Notifies)); }
/// <summary> /// INTERNAL API. /// </summary> /// <param name="reason">TBD</param> /// <returns>TBD</returns> internal State <TS, TD, TE> WithStopReason(FSMBase.Reason reason) { return(Copy(stopReason: reason)); }
/// <summary> /// TBD /// </summary> /// <param name="reason">TBD</param> /// <param name="stateData">TBD</param> /// <returns>TBD</returns> public State <TState, TData, TEvent> Stop(FSMBase.Reason reason, TData stateData) { return(Stay().Using(stateData).WithStopReason(reason)); }
/// <summary> /// Produce change descriptor to stop this FSM actor with the specified <see cref="FSMBase.Reason" />. /// </summary> /// <param name="reason">TBD</param> /// <returns>TBD</returns> public State <TState, TData, TEvent> Stop(FSMBase.Reason reason) { return(Stop(reason, _currentState.StateData)); }
/// <summary> /// Change FSM state. This method is directly equivalent to a /// corresponding transition initiated from within the FSM, including timeout /// and stop handling. /// </summary> /// <param name="stateName">TBD</param> /// <param name="stateData">TBD</param> /// <param name="timeout">TBD</param> /// <param name="stopReason">TBD</param> public void SetState(TState stateName, TData stateData, TimeSpan?timeout = null, FSMBase.Reason stopReason = null) { var fsm = ((IInternalSupportsTestFSMRef <TState, TData>)UnderlyingActor); InternalRef.Cell.UseThreadContext(() => fsm.ApplyState(new FSMBase.State <TState, TData>(stateName, stateData, timeout, stopReason))); }
/// <summary> /// Produce change descriptor to stop this FSM actor with the specified <see cref="FSMBase.Reason" />. /// </summary> public State Stop(FSMBase.Reason reason) { return(Stop(reason, _currentState.StateData)); }
/// <summary> /// TBD /// </summary> /// <param name="reason">TBD</param> /// <param name="stateData">TBD</param> /// <returns>TBD</returns> public State <TState, TData, TEvent> Stop(FSMBase.Reason reason, TData stateData) { return(Stay().Copy(stateData: stateData, stopReason: reason)); }