@@ -26,27 +26,27 @@ public static class ConditionExtensions {
26
26
27
27
/// <summary> If the condition is true, execute the action </summary>
28
28
public static void IfTrue ( this bool condition , Action action ) {
29
- if ( condition ) action ( ) ;
29
+ if ( condition ) action ? . Invoke ( ) ;
30
30
}
31
31
/// <summary> If the condition is true, execute the action </summary>
32
32
public static void IfTrue < T > ( this bool condition , Func < object > action ) {
33
- if ( condition ) action ( ) ;
33
+ if ( condition ) action ? . Invoke ( ) ;
34
34
}
35
35
36
36
/// <summary> If the condition is false, execute the action </summary>
37
37
public static void IfFalse ( this bool condition , Action action ) {
38
- if ( ! condition ) action ( ) ;
38
+ if ( ! condition ) action ? . Invoke ( ) ;
39
39
}
40
40
41
41
/// <summary> Select the action to perform based on the condition </summary>
42
42
public static void Select ( this bool condition , Action onTrue , Action onFalse ) {
43
- if ( condition ) onTrue ( ) ;
43
+ if ( condition ) onTrue ? . Invoke ( ) ;
44
44
else onFalse ( ) ;
45
45
}
46
46
47
47
/// <summary> Select the action to perform based on the condition </summary>
48
48
public static void Select < T > ( this bool condition , Action < T > onTrue , Action < T > onFalse , T arg ) {
49
- if ( condition ) onTrue ( arg ) ;
49
+ if ( condition ) onTrue ? . Invoke ( arg ) ;
50
50
else onFalse ( arg ) ;
51
51
}
52
52
@@ -58,11 +58,11 @@ public static void Select<T>(this bool condition, Action<T> onTrue, Action<T> on
58
58
59
59
/// <summary> Perform an action with passed arguments if true</summary>
60
60
public static void IfTrue < T > ( this bool condition , Action < T > action , T arg ) {
61
- if ( condition ) action ( arg ) ;
61
+ if ( condition ) action ? . Invoke ( arg ) ;
62
62
}
63
63
/// <summary> Perform an action with passed arguments if false</summary>
64
64
public static void IfFalse < T > ( this bool condition , Action < T > action , T arg ) {
65
- if ( ! condition ) action ( arg ) ;
65
+ if ( ! condition ) action ? . Invoke ( arg ) ;
66
66
}
67
67
68
68
public static void flip ( this ref bool condition ) => condition = ! condition ;
0 commit comments