Class DataContextScriptHost
class used for executing time cockpit python scripts.
Inheritance
Inherited Members
Namespace: TimeCockpit.Data
Assembly: TimeCockpit.Data.dll
Syntax
public class DataContextScriptHost
Constructors
DataContextScriptHost(DebugSettings)
Initializes a new instance of the DataContextScriptHost class.
Declaration
public DataContextScriptHost(DebugSettings settings = null)
Parameters
Type | Name | Description |
---|---|---|
DebugSettings | settings | Debug settings. |
Properties
DefaultDebugSettings
Gets or sets the default debug settings.
Declaration
public static DebugSettings DefaultDebugSettings { get; set; }
Property Value
Type | Description |
---|---|
DebugSettings |
Methods
CreateScope()
Initializes a new script scope.
Declaration
public ScriptScope CreateScope()
Returns
Type | Description |
---|---|
Microsoft.Scripting.Hosting.ScriptScope | returns the script scope. |
ExecuteScript(DataContext, ExecutionInfo, Boolean, ScriptScope, Stream)
Executes a dlr script.
Declaration
public void ExecuteScript(DataContext dataContext, ExecutionInfo script, bool inModelActionContext, ScriptScope scriptScope, Stream outputStream)
Parameters
Type | Name | Description |
---|---|---|
DataContext | dataContext | dataContext to execute script against. |
ExecutionInfo | script | The script to execute. |
System.Boolean | inModelActionContext | Indicates whether the script is called from a ModelAction. |
Microsoft.Scripting.Hosting.ScriptScope | scriptScope | ScriptScope to use. |
System.IO.Stream | outputStream | stream accepting output. |
ExecuteScript(DataContext, ExecutionInfo, Boolean, Stream)
Executes a dlr script.
Declaration
public void ExecuteScript(DataContext dataContext, ExecutionInfo script, bool inModelActionContext, Stream outputStream)
Parameters
Type | Name | Description |
---|---|---|
DataContext | dataContext | dataContext to execute script against. |
ExecutionInfo | script | The script to execute. |
System.Boolean | inModelActionContext | Indicates whether the script is called from a ModelAction. |
System.IO.Stream | outputStream | stream accepting output. |
ExecuteScript(DataContext, ExecutionInfo, Stream)
Executes a dlr script.
Declaration
public void ExecuteScript(DataContext dataContext, ExecutionInfo script, Stream outputStream)
Parameters
Type | Name | Description |
---|---|---|
DataContext | dataContext | dataContext to execute script against. |
ExecutionInfo | script | The script to execute. |
System.IO.Stream | outputStream | stream accepting output. |
ExecuteScriptFromResource(DataContext, Assembly, String, Stream)
Executes a dlr script, that is saved as embedded resource.
Declaration
public void ExecuteScriptFromResource(DataContext dataContext, Assembly assembly, string resourceName, Stream outputStream)
Parameters
Type | Name | Description |
---|---|---|
DataContext | dataContext | dataContext to pass to script for execution. |
System.Reflection.Assembly | assembly | The assembly, that contains the embedded resource. |
System.String | resourceName | The name of the embedded resource. |
System.IO.Stream | outputStream | stream accepting output. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown if the resource cannot be loaded from the assembly. |
GetFunctionScriptResult<T>(DataContext, ExecutionInfo, String, Object[], ScriptScope, Stream)
Executes a dlr script and returns an instance of ScriptResult.
Declaration
public T GetFunctionScriptResult<T>(DataContext dataContext, ExecutionInfo script, string functionName, object[] parameters, ScriptScope scope, Stream outputStream)
where T : class
Parameters
Type | Name | Description |
---|---|---|
DataContext | dataContext | datacontext to work against. |
ExecutionInfo | script | The script to execute. |
System.String | functionName | The name of the function to execute. |
System.Object[] | parameters | A list of parameters for the function. |
Microsoft.Scripting.Hosting.ScriptScope | scope | The scope to use. |
System.IO.Stream | outputStream | stream accepting output. |
Returns
Type | Description |
---|---|
T | An instance of ScriptResult |
Type Parameters
Name | Description |
---|---|
T | Type of the result |
GetScriptResult(DataContext, ExecutionInfo, ScriptScope, Stream)
Executes a dlr script and returns an instance of ScriptResult.
Declaration
public ScriptResult GetScriptResult(DataContext dataContext, ExecutionInfo script, ScriptScope scope, Stream outputStream)
Parameters
Type | Name | Description |
---|---|---|
DataContext | dataContext | datacontext to work against. |
ExecutionInfo | script | The script to execute. |
Microsoft.Scripting.Hosting.ScriptScope | scope | The scope to use. |
System.IO.Stream | outputStream | stream accepting output. |
Returns
Type | Description |
---|---|
ScriptResult | An instance of ScriptResult |
Remarks
ATTENTION: Per convetion the result of the script is only returned if it is assigned to a variable that starts with "result". Up to now, this method can only return a list of EntityObjects as result. Even if the actual result of the dynamic language script would be a single instance of EntityObject, the object is added to a list of EntityObject with the object being the only item in the list.
Examples
result = Context.SelectSingle("From P In Project Select P")