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
Mostrar archivo Open project: adamabdelhamed/PowerArgs

Protected Properties

Property Type Description
parentReaderContext RichCommandLineContext

Public Methods

Method 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.

Protected Methods

Method 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

Method 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 method

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
return bool

ClearMenu() public method

Clears the menu from the console
public ClearMenu ( RichCommandLineContext notUsed ) : void
notUsed RichCommandLineContext
return void

ContextAssistSearch() public method

Initializes the search assist class
public ContextAssistSearch ( ) : System
return System

DrawMenu() public method

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
return ContextAssistResult

GetResults() protected abstract method

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
return List

GetResultsAsync() protected abstract method

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
return Task>

OnKeyboardInput() public method

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
return ContextAssistResult

Search() public method

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.
return 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
return RichCommandLineContext