IGLib
1.5
The IGLib base library for development of numerical, technical and business applications.
|
Interface for simple command-line applicatino interpreters. More...
Public Member Functions | |
string | GetVariable (string varName) |
Returns the value of the specified variable of the current command line interpreter. null is returned if the specified variable does not exist. More... | |
string | SetVariable (string varName, string value) |
Sets the specified variable to the specified value. More... | |
string | ClearVariable (string varName) |
Clears (removes) the specified variable. More... | |
string | PrintVariable (string varName) |
Prints the specified variable. More... | |
string[] | GetArguments (string commandLine) |
Parses a command line and extracts arguments from it. Arguments can be separated according to usual rules for command-line arguments: spaces are separators, there can be arbitraty number of spaces, and if we want an argument to contain spaces, we must enclose it in double quotes. Command line can also contain the command name followed by arguments. In this case it is treated in the same way, and command can be obtained simply as the first string in the returned array. More... | |
string | RunFile (string filePath) |
Runs all commands that are written in a file. Each line of a file is interpreted as a single command, consisting of command name followed by arguments. More... | |
string | RunInteractive () |
Reads commands one by one from the standard input and executes them. More... | |
bool | ContainsCommand (string commandName) |
Returns true if the interpreter contains a command with specified name, false otherwise. More... | |
string | RunWithoutModifications (string commandName, params string[] commandArguments) |
Runs the specified command with specified name, installed on the current application object, without any modifications of the command arguments. More... | |
string | Run (string commandName, string[] args) |
Runs the command with specified name, installed on the current application object. More... | |
string | Run (string[] args) |
Runs command where the first argument is command name. Extracts application name and runs the corresponding application delegate.Before running it, arguments for the application delegate are extracted and then passed to the delegate. More... | |
string | RunAsync (string[] args) |
Runs a command asynchronously where the first argument is command name. Extracts command name and runs the corresponding application delegate. Before running it, arguments for the application delegate are extracted and then passed to the delegate. More... | |
string | RunAsync (string commandName, params string[] commandArguments) |
Runs the command with specified name (installed on the current interpreter object) asynchronously. More... | |
bool | AsyncIsCompleted (int id) |
Returns true if the asynchronous command execution identified by id has completed, and false otherwise. More... | |
void | AsyncWaitAll () |
Waits until all asynchronously commands that have been eventually executed by the current interpreter, complete. More... | |
string | AsyncWait (int callId) |
Waits for the specified asynchronous command (specified by command ID) to complete. More... | |
void | AddCommand (string appName, CommandLineApplicationInterpreter.ApplicationCommandDelegate appMain) |
Adds command with the specified name. More... | |
void | RemoveCommand (string appName) |
Removes the command with the specified name. More... | |
void | RemoveAllCommands () |
Removes all commands from the current interpreter. More... | |
void | AddModule (string moduleName, CommandLineApplicationInterpreter.ModuleDelegate moduleDelegate) |
Adds a new module to the interpreter. This adds an initialization function (via a delegate) which is executed when module module initialization is performed. More... | |
void | LoadModule (string moduleName) |
Loads and initializes the specified module. More... | |
bool | IsModuleLoaded (string moduleName) |
Returns true if the specified module has been loaded on the interpreter, false if not. More... | |
string | RunScriptFile (string scriptFilePath, string[] initAndRunArgs) |
Dynamically loads (temporarily, just for execution of the current commad) a class form the script contained in the specified file and executes its executable method. The file must contain the script that is dynamically loaded and executed, in form of definition of the appropriate class of type ILoadableScript. The dynamically loadable script class is loaded from the file and instantiated by the LoadableScriptInterpreter interpreter that is based on loadable scripts. More... | |
void | LoadScript (string newCommandName, string scriptFilePath, string[] initArgs) |
Dynamically loads (compiles and instantiates) a loadable script class contained in the specified file, and installs a new command on LoadableScriptInterpreter and on the current interpreter, based on the dynamically created instance of the loaded (dynamically compiled) class. More... | |
string | RunLoadedScript (string commandName, string[] arguments) |
Executes the specified command that has been dynamically loaded form a script. More... | |
string[] | GetLoadableScriptReferencedAssemblies () |
Returns an array of assemblies that are currently referenced by the script loader that takes care of loading the dynamic scripts. More... | |
Properties | |
string | Name [get, set] |
Name of the current interpreter. More... | |
string | Description [get, set] |
Description of hte current interpreter. More... | |
bool | Exit [get] |
Whether the exit flag is set, usually causing interpreter to stop. More... | |
StopWatch | Timer [get] |
Gets the stopwatch used for measuring time of commands. More... | |
int | OutputLevel [get, set] |
Level of output for some of the interpreter's functionality (e.g. asynchronous command execution). More... | |
bool | WarnCommandReplacement [get, set] |
Specifies whether a wrning should be launched whenever an installed command is being replaced. More... | |
LoadableScriptInterpreterBase | LoadableScriptInterpreter [get, set] |
Interprater based on dynamically loadable scripts. This enables installation and running of commands that are based on C# code that is dynamically compiled. Ihe object is created on first get access if it has not been assigned before. This property can be overridden in derived classes such that getter creates a dynamically loadable script - based interpreter of another kind. This is important because different script loaders (in particuar with different dynamic libraries referenced) will be used in different contexts. Another possibility is that a custom object is assigned to this property, usually in the initialization stage of the current interpreter. More... | |
Interface for simple command-line applicatino interpreters.
string IG.Lib.ICommandLineApplicationInterpreter.GetVariable | ( | string | varName | ) |
Returns the value of the specified variable of the current command line interpreter. null is returned if the specified variable does not exist.
varName | Name of the variable. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string IG.Lib.ICommandLineApplicationInterpreter.SetVariable | ( | string | varName, |
string | value | ||
) |
Sets the specified variable to the specified value.
varName | Name of the variable to be set. |
value | Value that is assigned to the variable. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string IG.Lib.ICommandLineApplicationInterpreter.ClearVariable | ( | string | varName | ) |
Clears (removes) the specified variable.
varName | Name of the variable to be cleared. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string IG.Lib.ICommandLineApplicationInterpreter.PrintVariable | ( | string | varName | ) |
Prints the specified variable.
varName | Name of the variable to be cleared. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string [] IG.Lib.ICommandLineApplicationInterpreter.GetArguments | ( | string | commandLine | ) |
Parses a command line and extracts arguments from it. Arguments can be separated according to usual rules for command-line arguments: spaces are separators, there can be arbitraty number of spaces, and if we want an argument to contain spaces, we must enclose it in double quotes. Command line can also contain the command name followed by arguments. In this case it is treated in the same way, and command can be obtained simply as the first string in the returned array.
commandLine | Command line that is split to individual arguments. Command line can also contain a command, which is treated equally. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string IG.Lib.ICommandLineApplicationInterpreter.RunFile | ( | string | filePath | ) |
Runs all commands that are written in a file. Each line of a file is interpreted as a single command, consisting of command name followed by arguments.
filePath | Path to the file containing commands. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string IG.Lib.ICommandLineApplicationInterpreter.RunInteractive | ( | ) |
Reads commands one by one from the standard input and executes them.
Implemented in IG.Lib.CommandLineApplicationInterpreter.
bool IG.Lib.ICommandLineApplicationInterpreter.ContainsCommand | ( | string | commandName | ) |
Returns true if the interpreter contains a command with specified name, false otherwise.
commandName | Name of the command whose existence is queried. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
Referenced by IG.Lib.LoadableScriptBase.Script_AddCommand().
string IG.Lib.ICommandLineApplicationInterpreter.RunWithoutModifications | ( | string | commandName, |
params string[] | commandArguments | ||
) |
Runs the specified command with specified name, installed on the current application object, without any modifications of the command arguments.
commandName | Command name. |
commandArguments | Command arguments. |
This method should not be overriden, but the Run(string, string[]) method can be, e.g. in order to perform some argument or command name transformations.
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string IG.Lib.ICommandLineApplicationInterpreter.Run | ( | string | commandName, |
string[] | args | ||
) |
Runs the command with specified name, installed on the current application object.
commandName | Command name. |
args | Command arguments. |
Referenced by IG.Lib.CommandLineJobContainer.RunCommand().
string IG.Lib.ICommandLineApplicationInterpreter.Run | ( | string[] | args | ) |
Runs command where the first argument is command name. Extracts application name and runs the corresponding application delegate.Before running it, arguments for the application delegate are extracted and then passed to the delegate.
args | Command arguments where the first argument is command name. The rest of the arguments are collected and passed to the command delegate. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string IG.Lib.ICommandLineApplicationInterpreter.RunAsync | ( | string[] | args | ) |
Runs a command asynchronously where the first argument is command name. Extracts command name and runs the corresponding application delegate. Before running it, arguments for the application delegate are extracted and then passed to the delegate.
args | Command arguments where the first argument is command name. The rest of the arguments are collected and passed to the command delegate. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string IG.Lib.ICommandLineApplicationInterpreter.RunAsync | ( | string | commandName, |
params string[] | commandArguments | ||
) |
Runs the command with specified name (installed on the current interpreter object) asynchronously.
commandName | Command name. |
commandArguments | Command arguments. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
bool IG.Lib.ICommandLineApplicationInterpreter.AsyncIsCompleted | ( | int | id | ) |
Returns true if the asynchronous command execution identified by id has completed, and false otherwise.
id | ID of the asynchronous command execution that is querried. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
void IG.Lib.ICommandLineApplicationInterpreter.AsyncWaitAll | ( | ) |
Waits until all asynchronously commands that have been eventually executed by the current interpreter, complete.
It is sometimes necessary to call this method if any asynchronous command invocations were made because such commands are executed in background threads, which are automatically broken when all foreground threads complete.
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string IG.Lib.ICommandLineApplicationInterpreter.AsyncWait | ( | int | callId | ) |
Waits for the specified asynchronous command (specified by command ID) to complete.
callId | ID of the asynchronous command execution. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
void IG.Lib.ICommandLineApplicationInterpreter.AddCommand | ( | string | appName, |
CommandLineApplicationInterpreter.ApplicationCommandDelegate | appMain | ||
) |
Adds command with the specified name.
appName | Name of the commant. |
appMain | Delegate that will be used to execute the command. |
Referenced by IG.Neural.NeuralAllpicationCommands.InstallCommands(), IG.Neural.NeuralApplicationCommandsTadej.InstallCommands(), IG.Lib.CommandLineApplicationInterpreter.ModuleTest1(), IG.Lib.CommandLineApplicationInterpreter.ModuleTest2(), and IG.Lib.LoadableScriptBase.Script_AddCommand().
void IG.Lib.ICommandLineApplicationInterpreter.RemoveCommand | ( | string | appName | ) |
Removes the command with the specified name.
appName | Name of the commad. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
Referenced by IG.Lib.LoadableScriptBase.Script_AddCommand(), and IG.Script.ScriptAppBase.Script_RemoveRunFileByScriptCommand().
void IG.Lib.ICommandLineApplicationInterpreter.RemoveAllCommands | ( | ) |
Removes all commands from the current interpreter.
Implemented in IG.Lib.CommandLineApplicationInterpreter.
Referenced by IG.Lib.LoadableScriptBase.Script_RemoveAllCommands().
void IG.Lib.ICommandLineApplicationInterpreter.AddModule | ( | string | moduleName, |
CommandLineApplicationInterpreter.ModuleDelegate | moduleDelegate | ||
) |
Adds a new module to the interpreter. This adds an initialization function (via a delegate) which is executed when module module initialization is performed.
moduleName | Name of the module. When used, module names are case sensitive if commands are case sensitive. |
moduleDelegate | Method that performs module initialization. |
void IG.Lib.ICommandLineApplicationInterpreter.LoadModule | ( | string | moduleName | ) |
Loads and initializes the specified module.
moduleName | Name of the module. It is case sensitive if commands are case sensitive. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
bool IG.Lib.ICommandLineApplicationInterpreter.IsModuleLoaded | ( | string | moduleName | ) |
Returns true if the specified module has been loaded on the interpreter, false if not.
moduleName | Name of the module. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string IG.Lib.ICommandLineApplicationInterpreter.RunScriptFile | ( | string | scriptFilePath, |
string[] | initAndRunArgs | ||
) |
Dynamically loads (temporarily, just for execution of the current commad) a class form the script contained in the specified file and executes its executable method. The file must contain the script that is dynamically loaded and executed, in form of definition of the appropriate class of type ILoadableScript. The dynamically loadable script class is loaded from the file and instantiated by the LoadableScriptInterpreter interpreter that is based on loadable scripts.
scriptFilePath | Path to the file containing loadable script must be the first argument to the method. |
initAndRunArgs | Initialization arguments for the object that will be instantiated in order to execute the script. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
void IG.Lib.ICommandLineApplicationInterpreter.LoadScript | ( | string | newCommandName, |
string | scriptFilePath, | ||
string[] | initArgs | ||
) |
Dynamically loads (compiles and instantiates) a loadable script class contained in the specified file, and installs a new command on LoadableScriptInterpreter and on the current interpreter, based on the dynamically created instance of the loaded (dynamically compiled) class.
newCommandName | Name of the newly installed command. |
scriptFilePath | Name of the file containing the script code that defines a loadable script class. |
initArgs | Arguments to the initialization method of the loaded object. The initialization method will be called before the first call to the executable method of the class, which takes care of execution of the newly installed command. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string IG.Lib.ICommandLineApplicationInterpreter.RunLoadedScript | ( | string | commandName, |
string[] | arguments | ||
) |
Executes the specified command that has been dynamically loaded form a script.
commandName | Name under which the command is installed on the current intepreter and on interpreder based on dynamically loaded scripts (LoadableScriptInterpreter). |
arguments | Arguments to the command. |
Implemented in IG.Lib.CommandLineApplicationInterpreter.
string [] IG.Lib.ICommandLineApplicationInterpreter.GetLoadableScriptReferencedAssemblies | ( | ) |
Returns an array of assemblies that are currently referenced by the script loader that takes care of loading the dynamic scripts.
Implemented in IG.Lib.CommandLineApplicationInterpreter.
|
getset |
Name of the current interpreter.
|
getset |
Description of hte current interpreter.
|
get |
Whether the exit flag is set, usually causing interpreter to stop.
|
get |
Gets the stopwatch used for measuring time of commands.
This property always returns an initialized stopwatch.
|
getset |
Level of output for some of the interpreter's functionality (e.g. asynchronous command execution).
|
getset |
Specifies whether a wrning should be launched whenever an installed command is being replaced.
|
getset |
Interprater based on dynamically loadable scripts. This enables installation and running of commands that are based on C# code that is dynamically compiled. Ihe object is created on first get access if it has not been assigned before. This property can be overridden in derived classes such that getter creates a dynamically loadable script - based interpreter of another kind. This is important because different script loaders (in particuar with different dynamic libraries referenced) will be used in different contexts. Another possibility is that a custom object is assigned to this property, usually in the initialization stage of the current interpreter.
ArgumentNullException | When set to null reference. |
$A Igor Aug11;