IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.
|
Dynamically compiles and loads classes from files or from strings. More...
Public Member Functions | |
ScriptLoaderBase () | |
virtual void | InitializeScriptLoader () |
Initializes the current script loader. | |
virtual void | ClearLogger () |
Clears the logger. | |
virtual string | GetExampleCode () |
Gets example code base (a template code for compiling) where names of classes, methods etc. are properly set. | |
virtual string | GetExampleCode (string pureScript) |
Returns a complete example code that can be loaded and run. | |
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). | |
virtual string | GetExecutableDirectory () |
Returns the directory containing the executable that started the current application. | |
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. | |
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. | |
virtual void | SetReferencedAssemblies (params string[] assemblyFiles) |
Sets the list of referenced assemblies in such a way that it contains only the specified assemblies. | |
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. | |
virtual void | RemoveReferencedAssemblies (params string[] assemblyFiles) |
Removes the specified assemblies from the list of referenced assemblies. | |
virtual void | RemoveAllReferencedAssemblies () |
Removes all assemblies from tehe list of referenced assemblies. | |
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. | |
virtual string | Compile () |
Compiles the code that is currently loaded by the current loader, and returns full name of the compiled script class. | |
virtual void | UnloadApplicationDomain () |
Unloads the application domain used by the current script loader. | |
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. | |
virtual ILoadableScript | CreateLoadableObject (string[] initializationArguments, bool storeObject) |
Creates and returns an object of the class that has been last compiled. | |
virtual ILoadableScript | CreateLoadableObject (string[] initializationArguments, string classFullName) |
Creates and returns an object of the specified loadable class. | |
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. | |
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. | |
void | LoadCode (string code, string className) |
Loads code form a string. | |
void | LoadCode (string code) |
Loads code form a string. Class name is extracted from the code. | |
ILoadableScript | CreateObjectFromCode (string code, string className, string[] initializationArguments) |
Creates and returns a loadable script object form code. | |
ILoadableScript | CreateObjectFromCode (string code, string[] initializationArguments) |
Creates and returns a loadable script object form code. Class name is extracted from code. | |
string | RunCode (string code, string className, string[] initializationArguments, string[] runArguments) |
Creates and runs a loadable script object form code. | |
string | RunCode (string code, string[] initializationArguments, string[] runArguments) |
Creates and returns a loadable script object form code. Class name is extracted from code. | |
string | RunCode (string code, string className, string[] initializationAndRunArguments) |
Runs a loadable script object form code. | |
string | RunCode (string code, string[] initializationAndRunArguments) |
Creates and returns a loadable script object form code. Class name is extracted from code. | |
void | LoadFile (string filePath, string className) |
Loads loadable script code form the specified file. | |
void | LoadFile (string filePath) |
Loads loadable script code form a file. Name of the class is extracted from the file contents. | |
ILoadableScript | CreateObjectFromFile (string filePath, string className, string[] initializationArguments) |
Creates and returns a loadable script object form a file containing its code. | |
ILoadableScript | CreateObjectFromFile (string filePath, string[] initializationArguments) |
Creates and returns a loadable script object form code. Class name is extracted from code. | |
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. | |
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. | |
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. | |
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. | |
Static Public Member Functions | |
static void | InitializeScripting () |
Initializes the scripting system. | |
static byte[] | LoadFileBytes (string filePath) |
Copies the specified file to byte array and returns it. | |
static ILoadableScript | CreateScriptObject (string scriptClassFullName) |
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). | |
static ILoadableScript | CreateScriptObject (string scriptClassFullName, int outputLevel) |
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). | |
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. | |
static void | RemoveDefaultAssemblies (params string[] assemblies) |
Removes the specified assemblies from the list of default assemblies that are referenced by newly created script loaders. | |
static void | ClearDefaultAssemblies () |
Clears the list of assemblies that are referenced by default by newly created script loaders. | |
static bool | IsClassFullNameUsed (string className) |
Returns a flag indicating whether the specified class full name has already been used or not. | |
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. | |
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. | |
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. | |
static string | GetFileContents (string filePath) |
Returns contents of the specified file. | |
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. Assemblies that are referenced by default can be set by the ScriptLoaderBase.AddDefaultAssemblies method. | |
void | CreateNonexistentLibraryPath () |
Modifies library path in such a way that it points to an non-existent file. | |
virtual void | AddReferencedAssemblies (System.CodeDom.Compiler.CompilerParameters compilerParameters) |
Adds referenced assemblies to the specified compiler parameters, according to current settings. | |
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. | |
Protected Attributes | |
string | _code |
string | _libraryFilename = null |
string | _originalLibraryPath = null |
List< string > | _referencedAssimblies = new List<string>() |
bool | _referenceAllLoadedAssemblies = true |
Properties | |
bool | IsScriptLoaderInitialized [get, set] |
Whether the current script loader is initialized or not. | |
static bool | IsScriptingInitialized [get, set] |
Whether scripting system is initialized or not. | |
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. | |
static List< string > | DefaultAssemblies [get] |
Gets the list of assemblies that are added to all newly created script loaders by default. | |
static SortedList< string, string > | UsedClassFullNames [get] |
Stores used class names. | |
static ScriptLoaderBase | Global [get, set] |
Global script loader. Getter always returns a non-null object. | |
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. | |
virtual Logger | Logger [get] |
Gets the logger that is used to log errors and warnings. | |
virtual string | Code [get, set] |
Gets or sets code to be compiled. Get: If not assigned explicitly then CodeBase is taken. | |
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. | |
virtual string | LanguageName [get, set] |
Language used by compiler. | |
virtual string | ClassNamespace [get, set] |
Namespace in which the compiled class is defined. | |
virtual string | ClassInterface [get] |
Interface that is implemented by the compiled class. | |
virtual string | ClassName [get, set] |
virtual string | ClassFullName [get] |
Name of the compiled class that contains loadable script. | |
virtual string | AppDomainName [get, set] |
Name of the application domain in which the class is loaded. | |
virtual string | RunFunctionName [get, set] |
Name of the method of dynamically loadable classes that contains the runnable script. | |
virtual string | InitFunctionName [get, set] |
Name of the initialization method of dynamically loadable classes. | |
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. | |
virtual string | LibraryFilename [get, set] |
virtual string | LibraryDirectory [get, set] |
Returns directory where library will be compiled, which will be the directory of the executable that started the application. | |
virtual string | LibraryPath [get, set] |
Path to the dll where code is compiled. We take the directory where executable is located. | |
virtual bool | IsCodeLoaded [get, set] |
Whether scripting code to be compiled is loaded. | |
virtual bool | IsCompiled [get, set] |
Whether the code is compiled. | |
virtual bool | IsClassLoaded [get, set] |
Whether the compiled class corresponding to the script is prepared. | |
virtual bool | IsObjectPrepared [get, set] |
Whether an instance of the object is prepared to be used. | |
virtual CompilerResults | CompilerResults [get, set] |
Results of compilation. | |
virtual List< String > | ReferencedAssemblies [get] |
List of assemblies that are referenced when compiling the code. Contains names of files containing referenced assemblies. | |
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. | |
virtual AppDomain | ApplicationDomain [get, set] |
Application domain used by the current script loader for loading assemblies. | |
virtual Assembly | Assembly [get, set] |
virtual ILoadableScript | CreatedObject [get, set] |
Object of the compiled class that has beeen created. | |
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 |
Dynamically compiles and loads classes from files or from strings.
$A Igor Jul09 Feb10;
IG::Lib::ScriptLoaderBase::ScriptLoaderBase | ( | ) | [inline] |
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 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).
scriptClassFullName | Full name of the script class whose object is created. |
outputLevel | Level of output to console. |
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).
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.
assemblies | Names of assemblies that are added to the list. |
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.
assemblies | names of assemblies that are removed from the list. |
static void IG::Lib::ScriptLoaderBase::ClearDefaultAssemblies | ( | ) | [inline, static] |
Clears the list of assemblies that are referenced by default by newly created script loaders.
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 | className | ) | [inline, static] |
Returns a flag indicating whether the specified class full name has already been used or not.
className | Fully qualified class name (namespace and class). |
virtual void IG::Lib::ScriptLoaderBase::ClearLogger | ( | ) | [inline, virtual] |
Clears the logger.
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.
code | String in which the specified name is searched for. |
allowedCharacters | Eventual string arguments that contains characters that are allowed beside the alphanumeric characters. |
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.
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.
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).
virtual string IG::Lib::ScriptLoaderBase::GetExecutableDirectory | ( | ) | [inline, virtual] |
Returns the directory containing the executable that started the current application.
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.
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.
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.
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.
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.
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.
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.
compilerParameters | Compiler parameters on which referenced assemblies ar added. |
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.
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.
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.
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.
initializationArguments | Initialization arguments. |
classFullName | Full name of the class that is instantiated. |
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.
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.
initializationArguments | Argumets used for initialization of the object. |
runArguments | Arguments used to run the object. |
void IG::Lib::ScriptLoaderBase::LoadCode | ( | string | code, |
string | className | ||
) | [inline] |
Loads code form a string.
code | String containing script code that is loaded. |
className | 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.
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.
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.
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.
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 mathod 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.
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.
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.
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.
filePath | Path to the file. |
void IG::Lib::ScriptLoaderBase::LoadFile | ( | string | filePath, |
string | className | ||
) | [inline] |
Loads loadable script code form the specified file.
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.
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.
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.
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.
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.
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.
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.
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. |
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 [protected] |
using System; using System.Collections; using System.IO; using System.Windows.Forms; using IG.Lib; namespace " { public class " { public "() { } protected override void "(string[] ") { } protected override string "(string[] ") { " return null; } } } " null
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] |
bool IG::Lib::ScriptLoaderBase::IsScriptLoaderInitialized [get, set] |
Whether the current script loader is initialized or not.
bool IG::Lib::ScriptLoaderBase::IsScriptingInitialized [static, get, 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.
Implements IG::Lib::ILockable.
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.
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, set] |
Language used by compiler.
virtual string IG::Lib::ScriptLoaderBase::ClassNamespace [get, 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, set] |
Name of the method of dynamically loadable classes that contains the runnable script.
virtual string IG::Lib::ScriptLoaderBase::InitFunctionName [get, 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, 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, set] |
Path to the dll where code is compiled. We take the directory where executable is located.
virtual bool IG::Lib::ScriptLoaderBase::IsCodeLoaded [get, set] |
Whether scripting code to be compiled is loaded.
virtual bool IG::Lib::ScriptLoaderBase::IsCompiled [get, set] |
Whether the code is compiled.
virtual bool IG::Lib::ScriptLoaderBase::IsClassLoaded [get, set] |
Whether the compiled class corresponding to the script is prepared.
virtual bool IG::Lib::ScriptLoaderBase::IsObjectPrepared [get, set] |
Whether an instance of the object is prepared to be used.
virtual CompilerResults IG::Lib::ScriptLoaderBase::CompilerResults [get, 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, set] |
virtual ILoadableScript IG::Lib::ScriptLoaderBase::CreatedObject [get, set] |
Object of the compiled class that has beeen created.