| IGLib 1.7.2 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Properties | Private Attributes | Static Private Attributes | List of all members
IG.Lib.ScriptLoaderBase Class Reference

Dynamically compiles, loads and instantiates classes of type ILoadableScript from files or from strings. More...

Inheritance diagram for IG.Lib.ScriptLoaderBase:
[legend]
Collaboration diagram for IG.Lib.ScriptLoaderBase:
[legend]

## Public Member Functions
| ScriptLoaderBase ()
virtual void | InitializeScriptLoader ()
| Initializes the current script loader. More...
virtual void | ClearLogger ()
| Clears the logger. More...
virtual string | GetExampleCode ()
| Gets example code base (a template code for compiling) where names of classes, methods etc. are properly set. More...
virtual string | GetExampleCode (string pureScript)
| Returns a complete example code that can be loaded and run. More...
void | CheckAndCorrectNames ()
| Corrects the ClassName (if the current class name has already been used) and namespace and class name in the loaded scritp code (if they don't correspond to ClassNamespace and ClassName, respectively). More...
virtual string | GetExecutableDirectory ()
| Returns the directory containing the executable that started the current application. More...
virtual void | AddReferencedAssembly (string assemblyFile)
| Adds an additional referenced assembly by name of the assembly file. Assmebly is only added if it is not yet contained in the list of referenced assemblies and if the specified assembly file name is not null or empty string. More...
virtual void | AddReferencedAssemblies (params string[] assemblyFiles)
| Adds the specified assemblies to the list of referenced assemblies. Assemblise are added only if not yet on the list and if their names are not null or empty strings. More...
virtual void | SetReferencedAssemblies (params string[] assemblyFiles)
| Sets the list of referenced assemblies in such a way that it contains only the specified assemblies. More...
virtual void | RemoveReferencedAssembly (string assemblyFile)
| Removes the specified assembly from the list of referenced assemblies. If the specified assembly does not exist on the list or it is a null or empty string then nothing happens. More...
virtual void | RemoveReferencedAssemblies (params string[] assemblyFiles)
| Removes the specified assemblies from the list of referenced assemblies. More...
virtual void | RemoveAllReferencedAssemblies ()
| Removes all assemblies from tehe list of referenced assemblies. More...
virtual string[] | GetReferencedAssemblies ()
| Returns an array of assemblies (paths, sometimes only file names) that are currently referenced by the compiler on the current script loader. More...
virtual string | Compile ()
| Compiles the code that is currently loaded by the current loader, and returns full name of the compiled script class. More...
virtual void | UnloadApplicationDomain ()
| Unloads the application domain used by the current script loader. More...
virtual ILoadableScript | CreateObject (string[] initializationArguments)
| Creates and returns an object of the class that has been last compiled. The created object is also stored such that it can later be accessed through the CreatedObject property. More...
virtual ILoadableScript | CreateLoadableObject (string[] initializationArguments, bool storeObject)
| Creates and returns an object of the class that has been last compiled. More...
virtual ILoadableScript | CreateLoadableObject (string[] initializationArguments, string classFullName)
| Creates and returns an object of the specified loadable class. More...
virtual void | Run (string[] initializationAndRunArguments)
| Runs the object of the compiled loadable class (calls its Run() method) that is currently loaded by the current loader. Compiles the code and creates the object if necessary. More...
virtual void | Run (string[] initializationArguments, string[] runArguments)
| Runs the object of the compiled loadable class (calls its Run() method) that is currently loaded by the current loader. Compiles the code and creates the object if necessary. More...
void | LoadCode (string code, string classFullName)
| Loads code form a string. More...
void | LoadCode (string code)
| Loads code form a string. Class name is extracted from the code. More...
ILoadableScript | CreateObjectFromCode (string code, string className, string[] initializationArguments)
| Creates and returns a loadable script object form code. More...
ILoadableScript | CreateObjectFromCode (string code, string[] initializationArguments)
| Creates and returns a loadable script object form code. Class name is extracted from code. More...
string | RunCode (string code, string className, string[] initializationArguments, string[] runArguments)
| Creates and runs a loadable script object form code. More...
string | RunCode (string code, string[] initializationArguments, string[] runArguments)
| Creates and returns a loadable script object form code. Class name is extracted from code. More...
string | RunCode (string code, string className, string[] initializationAndRunArguments)
| Runs a loadable script object form code. More...
string | RunCode (string code, string[] initializationAndRunArguments)
| Creates and returns a loadable script object form code. Class name is extracted from code. More...
void | LoadFile (string filePath, string className)
| Loads loadable script code form the specified file. More...
void | LoadFile (string filePath)
| Loads loadable script code form a file. Name of the class is extracted from the file contents. More...
ILoadableScript | CreateObjectFromFile (string filePath, string className, string[] initializationArguments)
| Creates and returns a loadable script object form a file containing its code. More...
ILoadableScript | CreateObjectFromFile (string filePath, string[] initializationArguments)
| Creates and returns a loadable script object form code. Class name is extracted from code. More...
string | RunFile (string filePath, string className, string[] initializationArguments, string[] runArguments)
| Executes a loadable script form a file. The file must contain definition of the loadable script class that is used to instantiate an object and execute it. More...
string | RunFile (string filePath, string[] initializationArguments, string[] runArguments)
| Executes a loadable script form a file. The file must contain definition of the loadable script class that is used to instantiate an object and execute it. Class name is extracted from code. More...
string | RunFile (string filePath, string className, string[] initializationAndRunArguments)
| Executes a loadable script form a file. The file must contain definition of the loadable script class that is used to instantiate an object and execute it. The same arguments are taken for initialization of the loadable script object and for execution of the script. More...
string | RunFile (string filePath, string[] initializationAndRunArguments)
| Executes a loadable script form a file. The file must contain definition of the loadable script class that is used to instantiate an object and execute it. The same arguments are taken for initialization of the loadable script object and for execution of the script. Class name is extracted from code. More...

## Static Public Member Functions
static void | InitializeScripting ()
| Initializes the scripting system. More...
static ILoadableScript | GetLoadableScriptC (ILoadableScript scriptObject)
| Returns the loadable script object if the script object is actually loadable, or null if it is not meant as loadable. More...
static byte[] | LoadFileBytes (string filePath)
| Copies the specified file to byte array and returns it. More...
static ILoadableScript | CreateScriptObject (string scriptClassFullName)
| Creates and returns a new script obect of the specified type. More...
static ILoadableScript | CreateScriptObject (string scriptClassFullName, int outputLevel)
| Creates and returns a new script obect of the specified type. More...
static void | AddDefaultAssemblies (params string[] assemblies)
| Add the specified assemblies (just their names) to the list of assemblies that are referenced by newly created script loaders by default. More...
static void | RemoveDefaultAssemblies (params string[] assemblies)
| Removes the specified assemblies from the list of default assemblies that are referenced by newly created script loaders. More...
static void | ClearDefaultAssemblies ()
| Clears the list of assemblies that are referenced by default by newly created script loaders. More...
static bool | IsClassFullNameUsed (string classFillName)
| Returns a flag indicating whether the specified class full name has already been used or not. More...
static string | FindNameAfterKeyword (string code, string keyword, string allowedCharacters)
| In the specified string, finds a name that follows the specified keyword, and returns it. Name must directly follow the keyword with only blank characters between them, and it end at the first character that is not alphanumeric and is also not contained in the specified string of allowed characters. More...
static string | FindNamespace (string code)
| Finds and returns the name of the first namespace that is defined in the specified C# code block. A null string is returned if the name can not be found. More...
static string | FindClassName (string code)
| Finds and returns the name of the first class that is defined in the specified C# code block. A null string is returned if the name can not be found. More...
static string | GetFileContents (string filePath)
| Returns contents of the specified file. More...

## Protected Member Functions
void | AddDefaultReferencedAssemblies ()
| Add assemblies that are referenced by default to the list of assemblies that are referenced by the current script loader. More...
void | CreateNonexistentLibraryPath ()
| Modifies library path in such a way that it points to an non-existent file. More...
virtual void | AddReferencedAssemblies (System.CodeDom.Compiler.CompilerParameters compilerParameters)
| Adds referenced assemblies to the specified compiler parameters, according to current settings. More...

## Static Protected Member Functions
static string | CreateNonexistentFilePath (string originalPath)
| Returns a file path that does not exist and is derived form the specified file path by adding a suffix composed of underscore and a number. More...

## Protected Attributes
string | _code = null
string | _libraryFilename = null
string | _originalLibraryPath = null
List< string > | _referencedAssimblies = new List<string>()
bool | _referenceAllLoadedAssemblies = true

## Properties
bool | IsScriptLoaderInitialized`[get, protected set]`
| Whether the current script loader is initialized or not. More...
static bool | IsScriptingInitialized`[get, protected set]`
| Whether scripting system is initialized or not. More...
object | Lock`[get]`
| This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. More...
static List< string > | DefaultAssemblies`[get]`
| Gets the list of assemblies that are added to all newly created script loaders by default. More...
static SortedList< string, string > | UsedClassFullNames`[get]`
| Stores used class names, i.e. class names that have already been used for dynamiically loaded classes. More...
static ScriptLoaderBase | Global`[get, set]`
| Global script loader. Getter always returns a non-null object. More...
int | OutputLevel`[get, set]`
| Definbes level of output on console that is generated by some operations. 0 means that no output will be written to the console. More...
virtual Logger | Logger`[get]`
| Gets the logger that is used to log errors and warnings. More...
virtual string | Code`[get, set]`
| Gets or sets code to be compiled. Get: If not assigned explicitly then CodeBase is taken. More...
bool | PerformNamesCorrection`[get, set]`
| Specifies whether automatic checking and correction of the class and namespace name in the loaded code is performed. If correction is switched on, it is performed before every compilation. Correction first checks if the class name has already been used, and if this is the case, it changes the name to the one that has not yet been used. It is then checked whether the namespace and class names used in the code are the same as those set on the current script loader. If not then names are replaced. At this stage, the assumed namespace class names are the first namespace and the first class found in the code block. More...
virtual string | LanguageName`[get, protected set]`
| Language used by compiler. More...
virtual string | ClassNamespace`[get, protected set]`
| Namespace in which the compiled class is defined. More...
virtual string | ClassInterface`[get]`
| Interface that is implemented by the compiled class. More...
virtual string | ClassName`[get, set]`
virtual string | ClassFullName`[get]`
| Name of the compiled class that contains loadable script. More...
virtual string | AppDomainName`[get, set]`
| Name of the application domain in which the class is loaded. More...
virtual string | RunFunctionName`[get, protected set]`
| Name of the method of dynamically loadable classes that contains the runnable script. More...
virtual string | InitFunctionName`[get, protected set]`
| Name of the initialization method of dynamically loadable classes. More...
virtual string | ArgumentsName`[get, set]`
| Agreed formal name of the arguments parameter. Agreement upon this name makes possible to execute scripts in which run arguments are referenced. More...
virtual string | LibraryFilename`[get, set]`
virtual string | LibraryDirectory`[get, protected set]`
| Returns directory where library will be compiled, which will be the directory of the executable that started the application. More...
virtual string | LibraryPath`[get, protected set]`
| Path to the dll where code is compiled. We take the directory where executable is located. More...
virtual bool | IsCodeLoaded`[get, protected set]`
| Whether scripting code to be compiled is loaded. More...
virtual bool | IsCompiled`[get, protected set]`
| Whether the code is compiled. More...
virtual bool | IsClassLoaded`[get, protected set]`
| Whether the compiled class corresponding to the script is prepared. More...
virtual bool | IsObjectPrepared`[get, protected set]`
| Whether an instance of the object is prepared to be used. More...
virtual CompilerResults | CompilerResults`[get, protected set]`
| Results of compilation. More...
virtual List< String > | ReferencedAssemblies`[get]`
| List of assemblies that are referenced when compiling the code. Contains names of files containing referenced assemblies. More...
virtual bool | ReferenceAllLoadedAssemblies`[get, set]`
| If true then all assemblies that are currently loaded by the application are also added to the referenced assemblies when script code is compiled. This makes sure that all that is necessary is actually referenced. More...
virtual AppDomain | ApplicationDomain`[get, set]`
| Application domain used by the current script loader for loading assemblies. More...
virtual Assembly | Assembly`[get, protected set]`
| Gets or sets the assembly that has been compiled and loaded into the current application domain from the source code. More...
virtual ILoadableScript | CreatedObject`[get, protected set]`
| Object of the compiled class that has beeen created. More...
Properties inherited from IG.Lib.ILockable
object | Lock`[get]`

## Private Attributes
bool | _isScriptLoaderInitialized = false
object | _mainLock = new object()
int | _outputLevel = Util.OutputLevel
Logger | _logger = new Logger()
bool | _nameCorrection = true
string | _languageName = "CSharp"
string | _namespace = "IG.Script"
string | _interface = "IG.Lib.ILoadableScript"
string | _className = "TestClass"
string | _appDomainName = "NewDomain"
string | _runFunctionName = "RunThis"
string | _initFunctionName = "InitializeThis"
string | _argumentsName = "arguments"
string | _libraryPath = null
string | _libraryDirectory = null
bool | _isCodeLoaded = false
bool | _isCompiled = false
bool | _isClassLoaded = false
bool | _isObjectPrepared = false
CompilerResults | _compilerResults
AppDomain | _applicationDomain
Assembly | _assembly
ILoadableScript | _runnableObject

## Static Private Attributes
static bool | _isScriptingInitialized = false
static List< string > | _defaultAssemblies
static SortedList< string, string > | _usedClassFullNames
static ScriptLoaderBase | _global

## Detailed Description

Dynamically compiles, loads and instantiates classes of type ILoadableScript from files or from strings.

$A Igor Jul09 Feb10;

## Constructor & Destructor Documentation

IG.Lib.ScriptLoaderBase.ScriptLoaderBase | ( |  | ) |
| inline

## Member Function Documentation

virtual void IG.Lib.ScriptLoaderBase.InitializeScriptLoader | ( |  | ) |
| inline virtual

Initializes the current script loader.

static void IG.Lib.ScriptLoaderBase.InitializeScripting | ( |  | ) |
| inline static

Initializes the scripting system.

static ILoadableScript IG.Lib.ScriptLoaderBase.GetLoadableScriptC | ( | ILoadableScript | scriptObject | ) |
| inline static

Returns the loadable script object if the script object is actually loadable, or null if it is not meant as loadable.

Parameters

  scriptObject | Script object to be returned if the object itself is loadable.

This method filters out the controllable loadable scripts (i.e. the scripts that implement the ILoadableScriptC interface) that are not loadable by property ILoadableScriptC.IsLoadable.

References IG.Lib.ILoadableScriptC.IsLoadable.

static byte [] IG.Lib.ScriptLoaderBase.LoadFileBytes | ( | string | filePath | ) |
| inline static

Copies the specified file to byte array and returns it.

TODO: move this to utils or something like that!

static ILoadableScript IG.Lib.ScriptLoaderBase.CreateScriptObject | ( | string | scriptClassFullName | ) |
| inline static

Creates and returns a new script obect of the specified type.

null is returned if the oject can not be created (but no exception is thrown).

Parameters

  scriptClassFullName | Full name of the script class whose object is created.

Referenced by IG.Lib.CommandLineApplicationInterpreter.CmdRunInternalScriptClass().

static ILoadableScript IG.Lib.ScriptLoaderBase.CreateScriptObject | ( | string | scriptClassFullName,
|  | int | outputLevel
| ) |  |
| inline static

Creates and returns a new script obect of the specified type.

null is returned if the oject can not be created (but no exception is thrown).

Parameters

  scriptClassFullName | Full name of the script class whose object is created.
  outputLevel | Level of output to console.

static void IG.Lib.ScriptLoaderBase.AddDefaultAssemblies | ( | params string[] | assemblies | ) |
| inline static

Add the specified assemblies (just their names) to the list of assemblies that are referenced by newly created script loaders by default.

Parameters

  assemblies | Names of assemblies that are added to the list.

References IG.Lib.Util.LockGlobal.

Referenced by IG.Lib.ApplicationCommandlineBase.AddDefaultAssemblies(), IG.Lib.ShellApplication< InterpreterType >.AddDefaultAssemblies(), IG.Lib.ModuleBase.AddDefaultAssembliesExtShellApp(), and IG.Lib.ModuleBase.AnnAdd().

static void IG.Lib.ScriptLoaderBase.RemoveDefaultAssemblies | ( | params string[] | assemblies | ) |
| inline static

Removes the specified assemblies from the list of default assemblies that are referenced by newly created script loaders.

Parameters

  assemblies | names of assemblies that are removed from the list.

References IG.Lib.Util.LockGlobal.

static void IG.Lib.ScriptLoaderBase.ClearDefaultAssemblies | ( |  | ) |
| inline static

Clears the list of assemblies that are referenced by default by newly created script loaders.

References IG.Lib.Util.LockGlobal.

void IG.Lib.ScriptLoaderBase.AddDefaultReferencedAssemblies | ( |  | ) |
| inline protected

Add assemblies that are referenced by default to the list of assemblies that are referenced by the current script loader.

Assemblies that are referenced by default can be set by the ScriptLoaderBase.AddDefaultAssemblies method.

static bool IG.Lib.ScriptLoaderBase.IsClassFullNameUsed | ( | string | classFillName | ) |
| inline static

Returns a flag indicating whether the specified class full name has already been used or not.

Parameters

  classFillName | Fully qualified class name (namespace and class).

virtual void IG.Lib.ScriptLoaderBase.ClearLogger | ( |  | ) |
| inline virtual

Clears the logger.

References IG.Lib.Logger.Clear().

virtual string IG.Lib.ScriptLoaderBase.GetExampleCode | ( |  | ) |
| inline virtual

Gets example code base (a template code for compiling) where names of classes, methods etc. are properly set.

virtual string IG.Lib.ScriptLoaderBase.GetExampleCode | ( | string | pureScript | ) |
| inline virtual

Returns a complete example code that can be loaded and run.

<pparam name="pureScript">Code that is inserted in the LoadableScriptBase.RunThis method.</pparam>

static string IG.Lib.ScriptLoaderBase.FindNameAfterKeyword | ( | string | code,
|  | string | keyword,
|  | string | allowedCharacters
| ) |  |
| inline static

In the specified string, finds a name that follows the specified keyword, and returns it. Name must directly follow the keyword with only blank characters between them, and it end at the first character that is not alphanumeric and is also not contained in the specified string of allowed characters.

Parameters

  code | String in which the specified name is searched for.
  keyword | Keyword.
  allowedCharacters | Eventual string arguments that contains characters that are allowed beside the alphanumeric characters.

Returns
  Name that follows the specified keyword.

This functions can be used e.g. for searching for class names or namespace names in code blocks. The method is currently not implemented very efficiently because it uses access to characters of a string through their within the string.

static string IG.Lib.ScriptLoaderBase.FindNamespace | ( | string | code | ) |
| inline static

Finds and returns the name of the first namespace that is defined in the specified C# code block. A null string is returned if the name can not be found.

Parameters

  code | Code block where namespace name is searched for.

static string IG.Lib.ScriptLoaderBase.FindClassName | ( | string | code | ) |
| inline static

Finds and returns the name of the first class that is defined in the specified C# code block. A null string is returned if the name can not be found.

Parameters

  code | Code block where class name is searched for.

void IG.Lib.ScriptLoaderBase.CheckAndCorrectNames | ( |  | ) |
| inline

Corrects the ClassName (if the current class name has already been used) and namespace and class name in the loaded scritp code (if they don't correspond to ClassNamespace and ClassName, respectively).

References IG.Lib.Logger.LogWarning().

virtual string IG.Lib.ScriptLoaderBase.GetExecutableDirectory | ( |  | ) |
| inline virtual

Returns the directory containing the executable that started the current application.

References IG.Lib.UtilSystem.GetExecutableDirectory().

virtual void IG.Lib.ScriptLoaderBase.AddReferencedAssembly | ( | string | assemblyFile | ) |
| inline virtual

Adds an additional referenced assembly by name of the assembly file. Assmebly is only added if it is not yet contained in the list of referenced assemblies and if the specified assembly file name is not null or empty string.

Parameters

  assemblyFile | File name of the assembly that is added to referenced assemblies.

virtual void IG.Lib.ScriptLoaderBase.AddReferencedAssemblies | ( | params string[] | assemblyFiles | ) |
| inline virtual

Adds the specified assemblies to the list of referenced assemblies. Assemblise are added only if not yet on the list and if their names are not null or empty strings.

Parameters

  assemblyFiles | A table of file names of the assemblies to be added.

virtual void IG.Lib.ScriptLoaderBase.SetReferencedAssemblies | ( | params string[] | assemblyFiles | ) |
| inline virtual

Sets the list of referenced assemblies in such a way that it contains only the specified assemblies.

Parameters

  assemblyFiles | Array of file names of the assemblies to be contained in the list.

virtual void IG.Lib.ScriptLoaderBase.RemoveReferencedAssembly | ( | string | assemblyFile | ) |
| inline virtual

Removes the specified assembly from the list of referenced assemblies. If the specified assembly does not exist on the list or it is a null or empty string then nothing happens.

Parameters

  assemblyFile | File name of the assembly to be removed.

virtual void IG.Lib.ScriptLoaderBase.RemoveReferencedAssemblies | ( | params string[] | assemblyFiles | ) |
| inline virtual

Removes the specified assemblies from the list of referenced assemblies.

Parameters

  assemblyFiles | Array of file names of the assemblies to be removed from the list.

virtual void IG.Lib.ScriptLoaderBase.RemoveAllReferencedAssemblies | ( |  | ) |
| inline virtual

Removes all assemblies from tehe list of referenced assemblies.

static string IG.Lib.ScriptLoaderBase.CreateNonexistentFilePath | ( | string | originalPath | ) |
| inline static protected

Returns a file path that does not exist and is derived form the specified file path by adding a suffix composed of underscore and a number.

Parameters

  originalPath | Original file path.

Even if the file with original path does not exist, the method finds and returns a new path.

void IG.Lib.ScriptLoaderBase.CreateNonexistentLibraryPath | ( |  | ) |
| inline protected

Modifies library path in such a way that it points to an non-existent file.

virtual void IG.Lib.ScriptLoaderBase.AddReferencedAssemblies | ( | System.CodeDom.Compiler.CompilerParameters | compilerParameters | ) |
| inline protected virtual

Adds referenced assemblies to the specified compiler parameters, according to current settings.

Parameters

  compilerParameters | Compiler parameters on which referenced assemblies ar added.

References IG.Lib.Logger.LogWarning().

virtual string [] IG.Lib.ScriptLoaderBase.GetReferencedAssemblies | ( |  | ) |
| inline virtual

Returns an array of assemblies (paths, sometimes only file names) that are currently referenced by the compiler on the current script loader.

virtual string IG.Lib.ScriptLoaderBase.Compile | ( |  | ) |
| inline virtual

Compiles the code that is currently loaded by the current loader, and returns full name of the compiled script class.

Returns
  Full name of the class implementing teh ILoadableScript interface that has been compiled.

References IG.Lib.Logger.GetErrorsReport(), IG.Lib.Logger.LogError(), IG.Lib.Logger.LogInfo(), and IG.Lib.Logger.LogWarning().

virtual void IG.Lib.ScriptLoaderBase.UnloadApplicationDomain | ( |  | ) |
| inline virtual

Unloads the application domain used by the current script loader.

virtual ILoadableScript IG.Lib.ScriptLoaderBase.CreateObject | ( | string[] | initializationArguments | ) |
| inline virtual

Creates and returns an object of the class that has been last compiled. The created object is also stored such that it can later be accessed through the CreatedObject property.

Parameters

  initializationArguments | Initialization arguments.

virtual ILoadableScript IG.Lib.ScriptLoaderBase.CreateLoadableObject | ( | string[] | initializationArguments,
|  | bool | storeObject
| ) |  |
| inline virtual

Creates and returns an object of the class that has been last compiled.

Parameters

  initializationArguments | Initialization arguments.
  storeObject | If true then the created object is stored such that it can be accessed via CreatedObject property.

virtual ILoadableScript IG.Lib.ScriptLoaderBase.CreateLoadableObject | ( | string[] | initializationArguments,
|  | string | classFullName
| ) |  |
| inline virtual

Creates and returns an object of the specified loadable class.

Parameters

  initializationArguments | Initialization arguments.
  classFullName | Full name of the class that is instantiated.

References IG.Lib.ILoadableScript.InitializationArguments.

virtual void IG.Lib.ScriptLoaderBase.Run | ( | string[] | initializationAndRunArguments | ) |
| inline virtual

Runs the object of the compiled loadable class (calls its Run() method) that is currently loaded by the current loader. Compiles the code and creates the object if necessary.

Parameters

  initializationAndRunArguments | Arguments used both for initialization and running of the object.

virtual void IG.Lib.ScriptLoaderBase.Run | ( | string[] | initializationArguments,
|  | string[] | runArguments
| ) |  |
| inline virtual

Runs the object of the compiled loadable class (calls its Run() method) that is currently loaded by the current loader. Compiles the code and creates the object if necessary.

Parameters

  initializationArguments | Argumets used for initialization of the object.
  runArguments | Arguments used to run the object.

void IG.Lib.ScriptLoaderBase.LoadCode | ( | string | code,
|  | string | classFullName
| ) |  |
| inline

Loads code form a string.

Parameters

  code | String containing script code that is loaded.
  classFullName | Name of the class that is contained in the code and contains loadable script that can be executed.

void IG.Lib.ScriptLoaderBase.LoadCode | ( | string | code | ) |
| inline

Loads code form a string. Class name is extracted from the code.

Parameters

  code | String containing script code that is loaded.

ILoadableScript IG.Lib.ScriptLoaderBase.CreateObjectFromCode | ( | string | code,
|  | string | className,
|  | string[] | initializationArguments
| ) |  |
| inline

Creates and returns a loadable script object form code.

Parameters

  code | Code that contains class definition and is dynamically compiled.
  className | Name of the class containing loadable script code.
  initializationArguments | Initialization arguments for the created object.

ILoadableScript IG.Lib.ScriptLoaderBase.CreateObjectFromCode | ( | string | code,
|  | string[] | initializationArguments
| ) |  |
| inline

Creates and returns a loadable script object form code. Class name is extracted from code.

Parameters

  code | Code that contains class definition and is dynamically compiled.
  initializationArguments | Initialization arguments for the created object.

string IG.Lib.ScriptLoaderBase.RunCode | ( | string | code,
|  | string | className,
|  | string[] | initializationArguments,
|  | string[] | runArguments
| ) |  |
| inline

Creates and runs a loadable script object form code.

Parameters

  code | Code that contains class definition and is dynamically compiled.
  className | Name of the class containing loadable script code.
  initializationArguments | Initialization arguments for the created object.
  runArguments | Arguments passed to the execution method of the loadable script.

string IG.Lib.ScriptLoaderBase.RunCode | ( | string | code,
|  | string[] | initializationArguments,
|  | string[] | runArguments
| ) |  |
| inline

Creates and returns a loadable script object form code. Class name is extracted from code.

Parameters

  code | Code that contains class definition and is dynamically compiled.
  initializationArguments | Initialization arguments for the created object.
  runArguments | Arguments passed to the execution mathod of the loadable script.

string IG.Lib.ScriptLoaderBase.RunCode | ( | string | code,
|  | string | className,
|  | string[] | initializationAndRunArguments
| ) |  |
| inline

Runs a loadable script object form code.

Parameters

  code | Code that contains class definition and is dynamically compiled.
  className | Name of the class containing loadable script code.
  initializationAndRunArguments | Arguments used both for initialization of the loadable script object and as parameters of the executable method..

string IG.Lib.ScriptLoaderBase.RunCode | ( | string | code,
|  | string[] | initializationAndRunArguments
| ) |  |
| inline

Creates and returns a loadable script object form code. Class name is extracted from code.

Parameters

  code | Code that contains class definition and is dynamically compiled.
  initializationAndRunArguments | Arguments used both for initialization of the loadable script object and as parameters of the executable method..

static string IG.Lib.ScriptLoaderBase.GetFileContents | ( | string | filePath | ) |
| inline static

Returns contents of the specified file.

Parameters

  filePath | Path to the file.

Returns
  Full contents of the file as string.

void IG.Lib.ScriptLoaderBase.LoadFile | ( | string | filePath,
|  | string | className
| ) |  |
| inline

Loads loadable script code form the specified file.

Parameters

  filePath | Path to the file that contains script code.
  className | Name of the class that is contained in the code and embeds loadable script that can be executed.

void IG.Lib.ScriptLoaderBase.LoadFile | ( | string | filePath | ) |
| inline

Loads loadable script code form a file. Name of the class is extracted from the file contents.

Parameters

  filePath | Path to the file that contains script code.

ILoadableScript IG.Lib.ScriptLoaderBase.CreateObjectFromFile | ( | string | filePath,
|  | string | className,
|  | string[] | initializationArguments
| ) |  |
| inline

Creates and returns a loadable script object form a file containing its code.

Parameters

  filePath | Path to the file that contains script code.
  className | Name of the class containing class definition for loadable script objects.
  initializationArguments | Initialization arguments for the created object.

ILoadableScript IG.Lib.ScriptLoaderBase.CreateObjectFromFile | ( | string | filePath,
|  | string[] | initializationArguments
| ) |  |
| inline

Creates and returns a loadable script object form code. Class name is extracted from code.

Parameters

  filePath | Path to the file that contains script code.
  initializationArguments | Initialization arguments for the created object.

string IG.Lib.ScriptLoaderBase.RunFile | ( | string | filePath,
|  | string | className,
|  | string[] | initializationArguments,
|  | string[] | runArguments
| ) |  |
| inline

Executes a loadable script form a file. The file must contain definition of the loadable script class that is used to instantiate an object and execute it.

Parameters

  filePath | Path to the file that contains script code.
  className | Name of the class containing loadable script code.
  initializationArguments | Initialization arguments for the created object.
  runArguments | Arguments passed to the execution mathod of the loadable script.

string IG.Lib.ScriptLoaderBase.RunFile | ( | string | filePath,
|  | string[] | initializationArguments,
|  | string[] | runArguments
| ) |  |
| inline

Executes a loadable script form a file. The file must contain definition of the loadable script class that is used to instantiate an object and execute it. Class name is extracted from code.

Parameters

  filePath | Path to the file that contains script code.
  initializationArguments | Initialization arguments for the created object.
  runArguments | Arguments passed to the execution mathod of the loadable script.

string IG.Lib.ScriptLoaderBase.RunFile | ( | string | filePath,
|  | string | className,
|  | string[] | initializationAndRunArguments
| ) |  |
| inline

Executes a loadable script form a file. The file must contain definition of the loadable script class that is used to instantiate an object and execute it. The same arguments are taken for initialization of the loadable script object and for execution of the script.

Parameters

  filePath | Path to the file that contains script code.
  className | Name of the class containing loadable script code.
  initializationAndRunArguments | Arguments used both for initialization of the loadable script object and as parameters of the executable method.

string IG.Lib.ScriptLoaderBase.RunFile | ( | string | filePath,
|  | string[] | initializationAndRunArguments
| ) |  |
| inline

Executes a loadable script form a file. The file must contain definition of the loadable script class that is used to instantiate an object and execute it. The same arguments are taken for initialization of the loadable script object and for execution of the script. Class name is extracted from code.

Parameters

  filePath | Path to the file that contains script code.
  initializationAndRunArguments | Arguments used both for initialization of the loadable script object and as parameters of the executable method.

## Member Data Documentation

bool IG.Lib.ScriptLoaderBase._isScriptLoaderInitialized = false
| private

bool IG.Lib.ScriptLoaderBase._isScriptingInitialized = false
| static private

object IG.Lib.ScriptLoaderBase._mainLock = new object()
| private

List<string> IG.Lib.ScriptLoaderBase._defaultAssemblies
| static private

SortedList<string, string> IG.Lib.ScriptLoaderBase._usedClassFullNames
| static private

ScriptLoaderBase IG.Lib.ScriptLoaderBase._global
| static private

int IG.Lib.ScriptLoaderBase._outputLevel = Util.OutputLevel
| private

Logger IG.Lib.ScriptLoaderBase._logger = new Logger()
| private

string IG.Lib.ScriptLoaderBase._code = null
| protected

bool IG.Lib.ScriptLoaderBase._nameCorrection = true
| private

string IG.Lib.ScriptLoaderBase._languageName = "CSharp"
| private

string IG.Lib.ScriptLoaderBase._namespace = "IG.Script"
| private

string IG.Lib.ScriptLoaderBase._interface = "IG.Lib.ILoadableScript"
| private

string IG.Lib.ScriptLoaderBase._className = "TestClass"
| private

string IG.Lib.ScriptLoaderBase._appDomainName = "NewDomain"
| private

string IG.Lib.ScriptLoaderBase._runFunctionName = "RunThis"
| private

string IG.Lib.ScriptLoaderBase._initFunctionName = "InitializeThis"
| private

string IG.Lib.ScriptLoaderBase._argumentsName = "arguments"
| private

string IG.Lib.ScriptLoaderBase._libraryFilename = null
| protected

string IG.Lib.ScriptLoaderBase._libraryPath = null
| private

string IG.Lib.ScriptLoaderBase._originalLibraryPath = null
| protected

string IG.Lib.ScriptLoaderBase._libraryDirectory = null
| private

bool IG.Lib.ScriptLoaderBase._isCodeLoaded = false
| private

bool IG.Lib.ScriptLoaderBase._isCompiled = false
| private

bool IG.Lib.ScriptLoaderBase._isClassLoaded = false
| private

bool IG.Lib.ScriptLoaderBase._isObjectPrepared = false
| private

CompilerResults IG.Lib.ScriptLoaderBase._compilerResults
| private

List<string> IG.Lib.ScriptLoaderBase._referencedAssimblies = new List<string>()
| protected

bool IG.Lib.ScriptLoaderBase._referenceAllLoadedAssemblies = true
| protected

AppDomain IG.Lib.ScriptLoaderBase._applicationDomain
| private

Assembly IG.Lib.ScriptLoaderBase._assembly
| private

ILoadableScript IG.Lib.ScriptLoaderBase._runnableObject
| private

## Property Documentation

bool IG.Lib.ScriptLoaderBase.IsScriptLoaderInitialized
| get protected set

Whether the current script loader is initialized or not.

bool IG.Lib.ScriptLoaderBase.IsScriptingInitialized
| static get protected set

Whether scripting system is initialized or not.

object IG.Lib.ScriptLoaderBase.Lock
| get

This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.

List<string> IG.Lib.ScriptLoaderBase.DefaultAssemblies
| static get protected

Gets the list of assemblies that are added to all newly created script loaders by default.

SortedList<string, string> IG.Lib.ScriptLoaderBase.UsedClassFullNames
| static get protected

Stores used class names, i.e. class names that have already been used for dynamiically loaded classes.

Every time a new class is dynamically loaded, its full name is added to this list.

ScriptLoaderBase IG.Lib.ScriptLoaderBase.Global
| static get set

Global script loader. Getter always returns a non-null object.

int IG.Lib.ScriptLoaderBase.OutputLevel
| get set

Definbes level of output on console that is generated by some operations. 0 means that no output will be written to the console.

virtual Logger IG.Lib.ScriptLoaderBase.Logger
| get

Gets the logger that is used to log errors and warnings.

virtual string IG.Lib.ScriptLoaderBase.Code
| get set

Gets or sets code to be compiled. Get: If not assigned explicitly then CodeBase is taken.

bool IG.Lib.ScriptLoaderBase.PerformNamesCorrection
| get set

Specifies whether automatic checking and correction of the class and namespace name in the loaded code is performed. If correction is switched on, it is performed before every compilation. Correction first checks if the class name has already been used, and if this is the case, it changes the name to the one that has not yet been used. It is then checked whether the namespace and class names used in the code are the same as those set on the current script loader. If not then names are replaced. At this stage, the assumed namespace class names are the first namespace and the first class found in the code block.

virtual string IG.Lib.ScriptLoaderBase.LanguageName
| get protected set

Language used by compiler.

virtual string IG.Lib.ScriptLoaderBase.ClassNamespace
| get protected set

Namespace in which the compiled class is defined.

virtual string IG.Lib.ScriptLoaderBase.ClassInterface
| get

Interface that is implemented by the compiled class.

virtual string IG.Lib.ScriptLoaderBase.ClassName
| get set

virtual string IG.Lib.ScriptLoaderBase.ClassFullName
| get

Name of the compiled class that contains loadable script.

virtual string IG.Lib.ScriptLoaderBase.AppDomainName
| get set

Name of the application domain in which the class is loaded.

virtual string IG.Lib.ScriptLoaderBase.RunFunctionName
| get protected set

Name of the method of dynamically loadable classes that contains the runnable script.

virtual string IG.Lib.ScriptLoaderBase.InitFunctionName
| get protected set

Name of the initialization method of dynamically loadable classes.

virtual string IG.Lib.ScriptLoaderBase.ArgumentsName
| get set

Agreed formal name of the arguments parameter. Agreement upon this name makes possible to execute scripts in which run arguments are referenced.

virtual string IG.Lib.ScriptLoaderBase.LibraryFilename
| get set

virtual string IG.Lib.ScriptLoaderBase.LibraryDirectory
| get protected set

Returns directory where library will be compiled, which will be the directory of the executable that started the application.

virtual string IG.Lib.ScriptLoaderBase.LibraryPath
| get protected set

Path to the dll where code is compiled. We take the directory where executable is located.

virtual bool IG.Lib.ScriptLoaderBase.IsCodeLoaded
| get protected set

Whether scripting code to be compiled is loaded.

virtual bool IG.Lib.ScriptLoaderBase.IsCompiled
| get protected set

Whether the code is compiled.

virtual bool IG.Lib.ScriptLoaderBase.IsClassLoaded
| get protected set

Whether the compiled class corresponding to the script is prepared.

virtual bool IG.Lib.ScriptLoaderBase.IsObjectPrepared
| get protected set

Whether an instance of the object is prepared to be used.

virtual CompilerResults IG.Lib.ScriptLoaderBase.CompilerResults
| get protected set

Results of compilation.

virtual List<String> IG.Lib.ScriptLoaderBase.ReferencedAssemblies
| get

List of assemblies that are referenced when compiling the code. Contains names of files containing referenced assemblies.

virtual bool IG.Lib.ScriptLoaderBase.ReferenceAllLoadedAssemblies
| get set

If true then all assemblies that are currently loaded by the application are also added to the referenced assemblies when script code is compiled. This makes sure that all that is necessary is actually referenced.

virtual AppDomain IG.Lib.ScriptLoaderBase.ApplicationDomain
| get set protected

Application domain used by the current script loader for loading assemblies.

virtual Assembly IG.Lib.ScriptLoaderBase.Assembly
| get protected set

Gets or sets the assembly that has been compiled and loaded into the current application domain from the source code.

Setter is protected.

virtual ILoadableScript IG.Lib.ScriptLoaderBase.CreatedObject
| get protected set

Object of the compiled class that has beeen created.

The documentation for this class was generated from the following file:

- igbase/interpreters/scriptloader/Loader.cs