@@ -17,9 +17,9 @@ private static Transition<TStateArgument, TEventArgument>.StateSelector<TState,
1717
1818 internal class Transitions : ITransitions
1919 {
20- protected readonly StateConfig StateConfig ;
20+ protected readonly StateConfig < Unit > StateConfig ;
2121
22- protected Transitions ( StateConfig stateConfig ) => StateConfig = stateConfig ;
22+ protected Transitions ( StateConfig < Unit > stateConfig ) => StateConfig = stateConfig ;
2323
2424 public ITransitions AddTransition ( TEvent @event , TState targetState , Transition < Unit , Unit > . Action < TState , TEvent > ? action = null )
2525 {
@@ -29,6 +29,8 @@ public ITransitions AddTransition(TEvent @event, TState targetState, Transition<
2929
3030 public ITransitions AddTransition < TEventArgument > ( TEvent @event , TState targetState , Transition < Unit , TEventArgument > . Action < TState , TEvent > action )
3131 {
32+ if ( action is null ) throw new ArgumentNullException ( nameof ( action ) ) ;
33+
3234 StateConfig . AddTransition ( @event , targetState , null , action ) ;
3335 return this ;
3436 }
@@ -39,6 +41,8 @@ public ITransitions AddConditionalTransition<TEventArgument>(
3941 Transition < Unit , TEventArgument > . Guard guard ,
4042 Transition < Unit , TEventArgument > . Action < TState , TEvent > ? action )
4143 {
44+ if ( guard is null ) throw new ArgumentNullException ( nameof ( guard ) ) ;
45+
4246 StateConfig . AddTransition ( @event , targetState , guard , action ) ;
4347 return this ;
4448 }
@@ -49,6 +53,8 @@ public ITransitions AddConditionalTransition(
4953 Transition < Unit , Unit > . Guard guard ,
5054 Transition < Unit , Unit > . Action < TState , TEvent > ? action )
5155 {
56+ if ( guard is null ) throw new ArgumentNullException ( nameof ( guard ) ) ;
57+
5258 StateConfig . AddTransition ( @event , targetState , guard , action ) ;
5359 return this ;
5460 }
@@ -59,6 +65,8 @@ public ITransitions AddConditionalTransition(
5965 Func < bool > guard ,
6066 Transition < Unit , Unit > . Action < TState , TEvent > ? action = null )
6167 {
68+ if ( guard is null ) throw new ArgumentNullException ( nameof ( guard ) ) ;
69+
6270 StateConfig . AddTransition ( @event , targetState , _ => guard ( ) , action ) ;
6371 return this ;
6472 }
@@ -78,6 +86,8 @@ public ITransitions AddDynamicTransition(
7886 Transition < Unit , Unit > . StateSelector < TState , TEvent > selector ,
7987 Transition < Unit , Unit > . Action < TState , TEvent > ? action = null )
8088 {
89+ if ( selector is null ) throw new ArgumentNullException ( nameof ( selector ) ) ;
90+
8191 StateConfig . AddTransition ( @event , selector , action ) ;
8292 return this ;
8393 }
@@ -87,12 +97,17 @@ public ITransitions AddDynamicTransition<TEventArgument>(
8797 Transition < Unit , TEventArgument > . StateSelector < TState , TEvent > selector ,
8898 Transition < Unit , TEventArgument > . Action < TState , TEvent > action )
8999 {
100+ if ( selector is null ) throw new ArgumentNullException ( nameof ( selector ) ) ;
101+ if ( action is null ) throw new ArgumentNullException ( nameof ( action ) ) ;
102+
90103 StateConfig . AddTransition ( @event , selector , action ) ;
91104 return this ;
92105 }
93106
94107 public ITransitions AddDynamicTransition ( TEvent @event , Func < TState ? > selector , Transition < Unit , Unit > . Action < TState , TEvent > ? action = null )
95108 {
109+ if ( selector is null ) throw new ArgumentNullException ( nameof ( selector ) ) ;
110+
96111 StateConfig . AddTransition ( @event , FuncToSelector < Unit , Unit > ( selector ) , action ) ;
97112 return this ;
98113 }
@@ -102,14 +117,22 @@ public ITransitions AddDynamicTransition<TEventArgument>(
102117 Func < TState ? > selector ,
103118 Transition < Unit , TEventArgument > . Action < TState , TEvent > action )
104119 {
120+ if ( selector is null ) throw new ArgumentNullException ( nameof ( selector ) ) ;
121+ if ( action is null ) throw new ArgumentNullException ( nameof ( action ) ) ;
122+
105123 StateConfig . AddTransition ( @event , FuncToSelector < Unit , TEventArgument > ( selector ) , action ) ;
106124 return this ;
107125 }
108126
109127 public void AllowReentrancy ( TEvent @event , Action ? action = null )
110128 => StateConfig . AddReentrantTransition < Unit > ( @event , action is null ? null : _ => action ( ) ) ;
111129
112- public void AllowReentrancy < TEventArgument > ( TEvent @event , Action < TEventArgument > action ) => StateConfig . AddReentrantTransition ( @event , action ) ;
130+ public void AllowReentrancy < TEventArgument > ( TEvent @event , Action < TEventArgument > action )
131+ {
132+ if ( action is null ) throw new ArgumentNullException ( nameof ( action ) ) ;
133+
134+ StateConfig . AddReentrantTransition ( @event , action ) ;
135+ }
113136 }
114137 }
115138}
0 commit comments