Class DlrScriptScope
Represents a scope for the dlr hosting system. A scope descriptes an area, where stuff is available and accessable
Inheritance
Inherited Members
Namespace: Simplic.Dlr
Assembly: Simplic.Dlr.dll
Syntax
public class DlrScriptScope
Constructors
| Improve this Doc View SourceDlrScriptScope(IDlrHost)
Create new DlrScope for executing base stuff
Declaration
public DlrScriptScope(IDlrHost host)
Parameters
Type | Name | Description |
---|---|---|
IDlrHost | host | Instance of the hosting component |
Properties
| Improve this Doc View SourceDynamicScriptScope
Get current dnymic script scope
Declaration
public dynamic DynamicScriptScope { get; }
Property Value
Type | Description |
---|---|
System.Object |
Host
Instance of the connected host
Declaration
public IDlrHost Host { get; }
Property Value
Type | Description |
---|---|
IDlrHost |
ScriptScope
Instance of the dlr script scope
Declaration
public ScriptScope ScriptScope { get; }
Property Value
Type | Description |
---|---|
ScriptScope |
Methods
| Improve this Doc View SourceCallFunction(String, Object[])
Call a function within the current scope
Declaration
public dynamic CallFunction(string name, params object[] parameter)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the function |
System.Object[] | parameter | List of parameter |
Returns
Type | Description |
---|---|
System.Object | Return value of the function |
ClearCache()
Clear cached expressions
Declaration
public void ClearCache()
CreateClassInstance(String, Object[])
Create an instance of an IronPython class
Declaration
public DlrClass CreateClassInstance(string className, params object[] parameter)
Parameters
Type | Name | Description |
---|---|---|
System.String | className | Name of the class |
System.Object[] | parameter | List of parameter which will be passed to the constructor |
Returns
Type | Description |
---|---|
DlrClass | Instance of a dlr class containing dlr meta class |
Execute(String, Boolean)
Execute a simple script expression
Declaration
public dynamic Execute(string expression, bool cache = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | Script expression as a string |
System.Boolean | cache | True if the expression should be cached |
Returns
Type | Description |
---|---|
System.Object | Result of the script expression as dynamic |
ExecutePreCompiledCode(String, ScriptScope)
Execute precompiled code and return result
Declaration
public dynamic ExecutePreCompiledCode(string name, ScriptScope otherScope = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Unique name of the scipt |
ScriptScope | otherScope | Deriving scope in which the script should be executed in |
Returns
Type | Description |
---|---|
System.Object | Result of the script/statement |
ExecuteScript(String, Boolean)
Execute a script. The script will be searched in all resolvers and the default search paths
Declaration
public dynamic ExecuteScript(string path, bool alwaysExecute = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Script path |
System.Boolean | alwaysExecute | If set to true, the script will be executed event if it was before. If set to false and the path was already executed, null will be returned |
Returns
Type | Description |
---|---|
System.Object | Result of the script execution |
GetVariable(String)
Get variable value by name
Declaration
public dynamic GetVariable(string variable)
Parameters
Type | Name | Description |
---|---|---|
System.String | variable | Name of the variable |
Returns
Type | Description |
---|---|
System.Object | Content of the variable |
IsScriptPathCached(String)
Returns whether a script was executed over ExecuteScript
Declaration
public bool IsScriptPathCached(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path to the script |
Returns
Type | Description |
---|---|
System.Boolean | True if the script was executed |
PreCompileCode(String, String, Boolean, Boolean)
Precompile code and store it in a dictioanry
Declaration
public void PreCompileCode(string name, string code, bool overrideExisting = true, bool isModule = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Unique name of the script, to access it later |
System.String | code | Code to compile |
System.Boolean | overrideExisting | True if existing scripts with the same name can be overriden. If set to false and the script alredy exists, an exception will be thrown |
System.Boolean | isModule | Register also as module, so it can be load with the |
RemoveCachedScriptPath(String)
Remove path from cache, so that a script from ExecuteScript will be executed the next time without using alwaysExecute = true
Declaration
public void RemoveCachedScriptPath(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path to the script |
SetVariable(String, Object)
Set the value of a variable in the current scope
Declaration
public void SetVariable(string variable, dynamic value)
Parameters
Type | Name | Description |
---|---|---|
System.String | variable | Name of the variable |
System.Object | value | Value of the variable |