Contains extension methods for TextPrompt.
Methods
public static TextPrompt<T> AddChoice<T>(TextPrompt<T> obj, T choice)
Adds a choice to the prompt.
Parameters:
obj (TextPrompt<T>)choice (T)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> AddChoices<T>(TextPrompt<T> obj, IEnumerable<T> choices)
Adds multiple choices to the prompt.
Parameters:
obj (TextPrompt<T>)choices (IEnumerable<T>)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> AllowEmpty<T>(TextPrompt<T> obj)
Allow empty input.
Parameters:
obj (TextPrompt<T>)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> ClearOnFinish<T>(TextPrompt<T> obj, bool clear = true)
Clears the prompt line after successful input.
Parameters:
obj (TextPrompt<T>)clear (bool)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> DefaultValue<T>(TextPrompt<T> obj, T value)
Sets the default value of the prompt.
Parameters:
obj (TextPrompt<T>)value (T)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> EditableDefaultValue<T>(TextPrompt<T> obj, bool state)
Whether or not to write the default value in the text input field to be modified by the end user.
Parameters:
obj (TextPrompt<T>)state (bool)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> HideChoices<T>(TextPrompt<T> obj)
Hides choices.
Parameters:
obj (TextPrompt<T>)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> HideDefaultValue<T>(TextPrompt<T> obj)
Hides the default value.
Parameters:
obj (TextPrompt<T>)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> InvalidChoiceMessage<T>(TextPrompt<T> obj, string message)
Sets the "invalid choice" message for the prompt.
Parameters:
obj (TextPrompt<T>)message (string)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> Secret<T>(TextPrompt<T> obj)
Replaces prompt user input with asterisks in the console.
Parameters:
obj (TextPrompt<T>)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> Secret<T>(TextPrompt<T> obj, char? mask)
Replaces prompt user input with mask in the console.
Parameters:
obj (TextPrompt<T>)mask (char?)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> ShowChoices<T>(TextPrompt<T> obj, bool show)
Show or hide choices.
Parameters:
obj (TextPrompt<T>)show (bool)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> ShowChoices<T>(TextPrompt<T> obj)
Shows choices.
Parameters:
obj (TextPrompt<T>)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> ShowDefaultValue<T>(TextPrompt<T> obj, bool show)
Show or hide the default value.
Parameters:
obj (TextPrompt<T>)show (bool)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> ShowDefaultValue<T>(TextPrompt<T> obj)
Shows the default value.
Parameters:
obj (TextPrompt<T>)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> Validate<T>(TextPrompt<T> obj, Func<T, bool> validator, string message = null)
Sets the validation criteria for the prompt.
Parameters:
obj (TextPrompt<T>)validator (Func<T, bool>)message (string)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> Validate<T>(TextPrompt<T> obj, Func<T, ValidationResult> validator)
Sets the validation criteria for the prompt.
Parameters:
obj (TextPrompt<T>)validator (Func<T, ValidationResult>)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> ValidationErrorMessage<T>(TextPrompt<T> obj, string message)
Sets the validation error message for the prompt.
Parameters:
obj (TextPrompt<T>)message (string)Returns:
The same instance so that multiple calls can be chained.
public static TextPrompt<T> WithConverter<T>(TextPrompt<T> obj, Func<T, string> displaySelector)
Sets the function to create a display string for a given choice.
Parameters:
obj (TextPrompt<T>)displaySelector (Func<T, string>)Returns:
The same instance so that multiple calls can be chained.