C# Class Crabwise.CommandWrap.Command

Provides an abstract representation of a command prompt command.
ファイルを表示 Open project: CrabwiseStudios/CommandWrap Class Usage Examples

Public Methods

Method Description
CancelAsync ( ) : void

Cancels the running command. Throws an exception if called on a command that is not executing.

CloseStandardInput ( ) : void

Closes the standard input to this command.

Execute ( ) : int

Executes this command with the default CommandStartInfo for this Command.

The default CommandStartInfo options can be set by deriving from this class and then overriding the Command.DefaultCommandStartInfo property.

Execute ( CommandStartInfo startInfo ) : int

Uses a CommandStartInfo object to execute this command.

ExecuteAsync ( ) : void

Executes the command with default starting parameters.

ExecuteAsync ( CommandStartInfo startInfo ) : void

Executes the command with custom starting parameters.

GetSyntax ( ) : string

Gets the command prompt String representation for this Command.

WaitForExit ( ) : void
WriteLineToStandardIn ( string input ) : void

Writes a System.String followed by a newline to the standard input of this command.

This method can only be used after Command.Execute() has been called.

WriteToStandardIn ( ICollection input ) : void

Writes a collection of strings to the standard input of this command.

This method can only be used after Command.Execute() has been called.

WriteToStandardIn ( string input ) : void

Writes a System.String to the standard input of this command.

This method can only be used after Command.Execute() has been called.

Protected Methods

Method Description
OnCommandStarting ( CommandStartingEventArgs e ) : void
OnErrorOutputWritten ( string outputLine ) : void
OnExecuteCompleted ( ) : void

Called when the command has finished running.

OnStandardOutputWritten ( string outputLine ) : void

Private Methods

Method Description
CleanupProcess ( ) : int

Handles all the finishing tasks within the command.

GetCommandSyntaxAttribute ( ) : CommandSyntaxAttribute

Gets the CommandSyntaxAttribute that adorns this command.

This method throws a SyntaxException if it cannot find a CommandSyntaxAttribute. This is generally wanted behavior since all classes implementing Command are required to have this attribute.

ProcessExited ( object sender, EventArgs e ) : void
StartProcess ( CommandStartInfo startInfo ) : void

Starts the process with customized starting information

Method Details

CancelAsync() public method

Cancels the running command. Throws an exception if called on a command that is not executing.
public CancelAsync ( ) : void
return void

CloseStandardInput() public method

Closes the standard input to this command.
public CloseStandardInput ( ) : void
return void

Execute() public method

Executes this command with the default CommandStartInfo for this Command.
The default CommandStartInfo options can be set by deriving from this class and then overriding the Command.DefaultCommandStartInfo property.
public Execute ( ) : int
return int

Execute() public method

Uses a CommandStartInfo object to execute this command.
public Execute ( CommandStartInfo startInfo ) : int
startInfo CommandStartInfo Specifies how to execute this command.
return int

ExecuteAsync() public method

Executes the command with default starting parameters.
public ExecuteAsync ( ) : void
return void

ExecuteAsync() public method

Executes the command with custom starting parameters.
public ExecuteAsync ( CommandStartInfo startInfo ) : void
startInfo CommandStartInfo The CommandStartInfo object that defines how the command should start
return void

GetSyntax() public method

Gets the command prompt String representation for this Command.
public GetSyntax ( ) : string
return string

OnCommandStarting() protected method

protected OnCommandStarting ( CommandStartingEventArgs e ) : void
e CommandStartingEventArgs
return void

OnErrorOutputWritten() protected method

protected OnErrorOutputWritten ( string outputLine ) : void
outputLine string
return void

OnExecuteCompleted() protected method

Called when the command has finished running.
protected OnExecuteCompleted ( ) : void
return void

OnStandardOutputWritten() protected method

protected OnStandardOutputWritten ( string outputLine ) : void
outputLine string
return void

WaitForExit() public method

public WaitForExit ( ) : void
return void

WriteLineToStandardIn() public method

Writes a System.String followed by a newline to the standard input of this command.
This method can only be used after Command.Execute() has been called.
public WriteLineToStandardIn ( string input ) : void
input string to write.
return void

WriteToStandardIn() public method

Writes a collection of strings to the standard input of this command.
This method can only be used after Command.Execute() has been called.
public WriteToStandardIn ( ICollection input ) : void
input ICollection of strings to write.
return void

WriteToStandardIn() public method

Writes a System.String to the standard input of this command.
This method can only be used after Command.Execute() has been called.
public WriteToStandardIn ( string input ) : void
input string to write.
return void