Пример #1
0
 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));
 }
Пример #2
0
 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;
 }
Пример #3
0
 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));
 }
Пример #4
0
 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);
 }
Пример #5
0
 /// <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());
         }
     }
 }
Пример #6
0
 /// <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());
         }
     });
 }
Пример #7
0
 /// <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;
 }
Пример #8
0
 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));
 }
Пример #9
0
 /// <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));
 }
Пример #10
0
 /// <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));
 }
Пример #11
0
 /// <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));
 }
Пример #12
0
        /// <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)));
        }
Пример #13
0
 /// <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));
 }
Пример #14
0
 /// <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));
 }