Class CommandShellContext
The shell context is the core of the command execution. Here are all commands registred. A ShellContext can be created of the ShellManager
Inheritance
Inherited Members
Namespace: Simplic.CommandShell
Assembly: Simplic.CommandShell.dll
Syntax
public class CommandShellContext
Constructors
| Improve this Doc View SourceCommandShellContext(String)
Create new shell context
Declaration
public CommandShellContext(string contextName)
Parameters
Type | Name | Description |
---|---|---|
System.String | contextName |
Properties
| Improve this Doc View SourceContextName
Unique name of the context
Declaration
public string ContextName { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceExecute(String, out Boolean)
Execute a shell command
Declaration
public string Execute(string command, out bool errorOccured)
Parameters
Type | Name | Description |
---|---|---|
System.String | command | Command line content |
System.Boolean | errorOccured | Out parameter which defines wether an error occured |
Returns
Type | Description |
---|---|
System.String | Return-Message of the execute method |
ExecuteMultiline(String, Boolean, out Boolean)
Execute multiple commands
Declaration
public string ExecuteMultiline(string commands, bool continueOnError, out bool errorOccured)
Parameters
Type | Name | Description |
---|---|---|
System.String | commands | String with commands |
System.Boolean | continueOnError | Continue if one of the commands failed |
System.Boolean | errorOccured | Continues if an error occurse |
Returns
Type | Description |
---|---|
System.String | Result-String |
RegisterMethod(String, CommandShellCommandDelegate, String[])
Register a method to the shell context
Declaration
public void RegisterMethod(string cmdName, CommandShellCommandDelegate methodDelegate, params string[] requiredParameter)
Parameters
Type | Name | Description |
---|---|---|
System.String | cmdName | name of the cmd, must be unique in one shell context |
CommandShellCommandDelegate | methodDelegate | Delegate to the .Net method |
System.String[] | requiredParameter | name of the required parameter, so that the system will automatically return an error if not all parameter were passed |
RegisterMethod(String, Object, String, String[])
Register a method to the shell context
Declaration
public void RegisterMethod(string cmdName, object classInstance, string methodName, string[] requiredParameter)
Parameters
Type | Name | Description |
---|---|---|
System.String | cmdName | name of the cmd, must be unique in one shell context |
System.Object | classInstance | Instance of a class |
System.String | methodName | Name of the method |
System.String[] | requiredParameter | All parameter |
RegisterStaticMethod(String, Type, String, String[])
Register a static method to the shell context
Declaration
public void RegisterStaticMethod(string cmdName, Type classType, string methodName, string[] requiredParameter)
Parameters
Type | Name | Description |
---|---|---|
System.String | cmdName | name of the cmd, must be unique in one shell context |
System.Type | classType | Type of the static class or the class instance |
System.String | methodName | Name of the method |
System.String[] | requiredParameter | All parameter |