/// <inheritdoc/> public T Show(IAnsiConsole console) { // Create the list prompt var prompt = new ListPrompt <T>(console, this); var result = prompt.Show(_tree); // Return the selected item return(result.Items[result.Index].Data); }
/// <inheritdoc/> public async Task <T> ShowAsync(IAnsiConsole console, CancellationToken cancellationToken) { // Create the list prompt var prompt = new ListPrompt <T>(console, this); var result = await prompt.Show(_tree, cancellationToken, PageSize).ConfigureAwait(false); // Return the selected item return(result.Items[result.Index].Data); }
/// <inheritdoc/> public List <T> Show(IAnsiConsole console) { // Create the list prompt var prompt = new ListPrompt <T>(console, this); var result = prompt.Show(_tree, PageSize); if (Mode == SelectionMode.Leaf) { return(result.Items .Where(x => x.Selected && x.Children.Count == 0) .Select(x => x.Data) .ToList()); } return(result.Items .Where(x => x.Selected) .Select(x => x.Data) .ToList()); }
/// <inheritdoc/> public async Task <List <T> > ShowAsync(IAnsiConsole console, CancellationToken cancellationToken) { // Create the list prompt var prompt = new ListPrompt <T>(console, this); var result = await prompt.Show(Tree, cancellationToken, PageSize).ConfigureAwait(false); if (Mode == SelectionMode.Leaf) { return(result.Items .Where(x => x.IsSelected && x.Children.Count == 0) .Select(x => x.Data) .ToList()); } return(result.Items .Where(x => x.IsSelected) .Select(x => x.Data) .ToList()); }