2
2
3
3
using System ;
4
4
using System . Collections . Generic ;
5
- using System . Threading . Tasks ;
6
5
7
6
namespace CommandLine
8
7
{
@@ -29,24 +28,6 @@ public static ParserResult<T> WithParsed<T>(this ParserResult<T> result, Action<
29
28
return result ;
30
29
}
31
30
32
- /// <summary>
33
- /// Executes asynchronously <paramref name="action"/> if <see cref="CommandLine.ParserResult{T}"/> contains
34
- /// parsed values.
35
- /// </summary>
36
- /// <typeparam name="T">Type of the target instance built with parsed value.</typeparam>
37
- /// <param name="result">An <see cref="CommandLine.ParserResult{T}"/> instance.</param>
38
- /// <param name="action">The <see cref="Func{T, Task}"/> to execute.</param>
39
- /// <returns>The same <paramref name="result"/> instance as a <see cref="Task"/> instance.</returns>
40
- public static async Task < ParserResult < T > > WithParsedAsync < T > ( this ParserResult < T > result , Func < T , Task > action )
41
- {
42
- if ( result is Parsed < T > parsed )
43
- {
44
- await action ( parsed . Value ) ;
45
- }
46
- return result ;
47
- }
48
-
49
-
50
31
/// <summary>
51
32
/// Executes <paramref name="action"/> if parsed values are of <typeparamref name="T"/>.
52
33
/// </summary>
@@ -67,26 +48,6 @@ public static ParserResult<object> WithParsed<T>(this ParserResult<object> resul
67
48
return result ;
68
49
}
69
50
70
- /// <summary>
71
- /// Executes asynchronously <paramref name="action"/> if parsed values are of <typeparamref name="T"/>.
72
- /// </summary>
73
- /// <typeparam name="T">Type of the target instance built with parsed value.</typeparam>
74
- /// <param name="result">An verb result instance.</param>
75
- /// <param name="action">The <see cref="Func{T, Task}"/> to execute.</param>
76
- /// <returns>The same <paramref name="result"/> instance as a <see cref="Task"/> instance.</returns>
77
- public static async Task < ParserResult < object > > WithParsedAsync < T > ( this ParserResult < object > result , Func < T , Task > action )
78
- {
79
- if ( result is Parsed < object > parsed )
80
- {
81
- if ( parsed . Value is T )
82
- {
83
- await action ( ( T ) parsed . Value ) ;
84
- }
85
- }
86
- return result ;
87
- }
88
-
89
-
90
51
/// <summary>
91
52
/// Executes <paramref name="action"/> if <see cref="CommandLine.ParserResult{T}"/> lacks
92
53
/// parsed values and contains errors.
@@ -96,28 +57,11 @@ public static async Task<ParserResult<object>> WithParsedAsync<T>(this ParserRes
96
57
/// <param name="action">The <see cref="System.Action"/> delegate to execute.</param>
97
58
/// <returns>The same <paramref name="result"/> instance.</returns>
98
59
public static ParserResult < T > WithNotParsed < T > ( this ParserResult < T > result , Action < IEnumerable < Error > > action )
99
- {
100
- if ( result is NotParsed < T > notParsed )
101
- {
102
- action ( notParsed . Errors ) ;
103
- }
104
- return result ;
105
- }
106
-
107
- /// <summary>
108
- /// Executes asynchronously <paramref name="action"/> if <see cref="CommandLine.ParserResult{T}"/> lacks
109
- /// parsed values and contains errors.
110
- /// </summary>
111
- /// <typeparam name="T">Type of the target instance built with parsed value.</typeparam>
112
- /// <param name="result">An <see cref="CommandLine.ParserResult{T}"/> instance.</param>
113
- /// <param name="action">The <see cref="System.Func{Task}"/> delegate to execute.</param>
114
- /// <returns>The same <paramref name="result"/> instance as a <see cref="Task"/> instance.</returns>
115
- public static async Task < ParserResult < T > > WithNotParsedAsync < T > ( this ParserResult < T > result , Func < IEnumerable < Error > , Task > action )
116
60
{
117
61
var notParsed = result as NotParsed < T > ;
118
62
if ( notParsed != null )
119
63
{
120
- await action ( notParsed . Errors ) ;
64
+ action ( notParsed . Errors ) ;
121
65
}
122
66
return result ;
123
67
}
0 commit comments