C# Class PowerArgs.ContextAssistSearch

A context assist provider that lets a user search for an option. The class is abstract. Implementors just need to define the search implementation and this class will do the rest.
Inheritance: IContextAssistProvider
Afficher le fichier Open project: adamabdelhamed/PowerArgs

Protected Properties

Свойство Type Description
parentReaderContext RichCommandLineContext

Méthodes publiques

Méthode Description
CanAssist ( RichCommandLineContext parentContext ) : bool

Always returns true. When overrided in a derived class the derived class can provide custom logic to determine whether or not this assist provider can assist.

ClearMenu ( RichCommandLineContext notUsed ) : void

Clears the menu from the console

ContextAssistSearch ( ) : System

Initializes the search assist class

DrawMenu ( RichCommandLineContext parentContext ) : ContextAssistResult

Writes the prompt message and takes over the console until the user makes a selection or cancels via the escape key. This method never returns a NoOp result.

OnKeyboardInput ( RichCommandLineContext parentReaderContext, ConsoleKeyInfo keyPress ) : ContextAssistResult

This is not implemented because this assist provider always takes over the console during the draw menu.

Search ( IConsoleProvider console = null, bool allowCancel = true ) : ContextAssistSearchResult

Performs a standalone search and cleans up the menu at the end.

Méthodes protégées

Méthode Description
GetResults ( string searchString ) : List

When implemented in the derived class, gets search results that match the search string. This ONLY gets called if SupportsAsync returns false.

GetResultsAsync ( string searchString ) : Task>

When implemented in the derived class, gets search results that match the search string asynchronously. This ONLY gets called if SupportsAsync returns true.

Private Methods

Méthode Description
DoSearch ( string searchString ) : void
DoSearchInternal ( RichCommandLineContext parentContext, IConsoleProvider standaloneConsole, bool allowCancel ) : void
RedrawSearchResults ( ) : void
_MoveSelectedIndex ( int amount ) : void
_SearchReader_HandleEnterKey ( RichCommandLineContext searchReaderContext ) : void
_SearchReader_HandleKeyPressed ( RichCommandLineContext searchReaderContext ) : void

Method Details

CanAssist() public méthode

Always returns true. When overrided in a derived class the derived class can provide custom logic to determine whether or not this assist provider can assist.
public CanAssist ( RichCommandLineContext parentContext ) : bool
parentContext RichCommandLineContext context about the parent reader that we may be assisting
Résultat bool

ClearMenu() public méthode

Clears the menu from the console
public ClearMenu ( RichCommandLineContext notUsed ) : void
notUsed RichCommandLineContext
Résultat void

ContextAssistSearch() public méthode

Initializes the search assist class
public ContextAssistSearch ( ) : System
Résultat System

DrawMenu() public méthode

Writes the prompt message and takes over the console until the user makes a selection or cancels via the escape key. This method never returns a NoOp result.
public DrawMenu ( RichCommandLineContext parentContext ) : ContextAssistResult
parentContext RichCommandLineContext context about the parent reader that we are assisting
Résultat ContextAssistResult

GetResults() protected abstract méthode

When implemented in the derived class, gets search results that match the search string. This ONLY gets called if SupportsAsync returns false.
protected abstract GetResults ( string searchString ) : List
searchString string the search string entered by the user
Résultat List

GetResultsAsync() protected abstract méthode

When implemented in the derived class, gets search results that match the search string asynchronously. This ONLY gets called if SupportsAsync returns true.
protected abstract GetResultsAsync ( string searchString ) : Task>
searchString string the search string entered by the user
Résultat Task>

OnKeyboardInput() public méthode

This is not implemented because this assist provider always takes over the console during the draw menu.
public OnKeyboardInput ( RichCommandLineContext parentReaderContext, ConsoleKeyInfo keyPress ) : ContextAssistResult
parentReaderContext RichCommandLineContext not implemented
keyPress System.ConsoleKeyInfo not implemented
Résultat ContextAssistResult

Search() public méthode

Performs a standalone search and cleans up the menu at the end.
public Search ( IConsoleProvider console = null, bool allowCancel = true ) : ContextAssistSearchResult
console IConsoleProvider Optionally choose a custom console target
allowCancel bool if true, users can cancel the search by pressing the escape key. If false, the escape key does nothing.
Résultat ContextAssistSearchResult

Property Details

parentReaderContext protected_oe property

context about the parent reader that is only populated when used by a parent reader.
protected RichCommandLineContext parentReaderContext
Résultat RichCommandLineContext