Code
·
27 lines
·
1002 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27// https://github.com/mattj23/InteractiveReadLine
#nullable disable
namespace InteractiveReadLine
{
public static class ExtensionMethods
{
/// <summary>
/// Interactively read a line of text from the provider, using a specified configuration if one is
/// given as an optional argument.
/// </summary>
/// <param name="provider">the IReadLineProvider provider which will perform the interaction with the user (for
/// example, the ConsoleReadLine object which wraps System.Console)</param>
/// <param name="config">The configuration to use for this specific interaction</param>
/// <returns>the text read from the user</returns>
public static string ReadLine(this IReadLineProvider provider, ReadLineConfig config=null)
{
using (provider)
{
var handler = new ReadLineHandler(provider, config);
return handler.ReadLine();
}
}
}
}