Exemplo n.º 1
0
        public Task <string> ReadLineAsync(char?mask, CancellationToken token = default)
        {
            var viewOptions = mask.HasValue
                ? LineViewOptions.Masked(mask.Value)
                : LineViewOptions.Hidden;

            return(ReadLineAsync(viewOptions, token));
        }
Exemplo n.º 2
0
        private async Task <string> ReadLineAsync(LineViewOptions viewOptions, CancellationToken token)
        {
            ThrowIfCancellationRequested(token, hadUserInput: false);

            var lineView = _viewProvider.GetView(viewOptions);

            try
            {
                await _viewEditor.Edit(lineView, token);

                _console.WriteLine();
                return(lineView.ToString());
            }
            catch (OperationCanceledException)
            {
                ThrowIfCancellationRequested(token, hadUserInput: lineView.Length > 0);
            }

            return(default(string));
        }