Class ScriptScopeWrapper
Represents a wrapper for the Microsoft.Scripting.Hosting.ScriptScope class. ExternalVariables returns all variables that where added by SetVariable(String, Object).
Inherited Members
Namespace: Loehnert.Lisrt.Scripting.Python
Assembly: Loehnert.Lisrt.Scripting.dll
Syntax
public class ScriptScopeWrapper
Properties
ExternalVariables
Gets the variables that were added by SetVariable(String, Object).
Declaration
public IReadOnlyDictionary<string, object> ExternalVariables { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyDictionary<String, Object> |
Methods
ContainsVariable(String)
Determines if this context or any outer scope contains the defined name.
Declaration
public bool ContainsVariable(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of the variable. |
Returns
Type | Description |
---|---|
Boolean | True when a variable named |
GetItems()
Gets all variables.
Declaration
public IEnumerable<KeyValuePair<string, dynamic>> GetItems()
Returns
Type | Description |
---|---|
IEnumerable<System.Collections.Generic.KeyValuePair<String, Object>> | All variables in the scope. |
GetVariable(String)
Gets a value stored in the scope under the given name.
Declaration
public dynamic GetVariable(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of the variable. |
Returns
Type | Description |
---|---|
Object | Value of the variable. |
Exceptions
Type | Condition |
---|---|
MissingMemberException | Thrown when the specified name is not defined in the scope. |
System.ArgumentNullException | Thrown when |
GetVariable<T>(String)
Gets a value stored in the scope under the given name. Converts the result to the specified type using the conversion that the language associated with the scope defines. If no language is associated with the scope, the default CLR conversion is attempted.
Declaration
public T GetVariable<T>(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of the variable. |
Returns
Type | Description |
---|---|
T | The converted value of the variable. |
Type Parameters
Name | Description |
---|---|
T | Type to convert the variable value. |
GetVariableNames()
Gets all names of all variables.
Declaration
public IEnumerable<string> GetVariableNames()
Returns
Type | Description |
---|---|
IEnumerable<String> | Names of variables. |
RemoveVariable(String)
Removes the variable of the given name from this scope.
Declaration
public bool RemoveVariable(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of the variable. |
Returns
Type | Description |
---|---|
Boolean | true if the value existed in the scope before it has been removed. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
SetVariable(String, Object)
Sets the name to the specified value.
Declaration
public void SetVariable(string name, object value)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of the variable. |
Object | value | Value of the variable. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
TryGetVariable(String, out Object)
Tries to get a value stored in the scope under the given name.
Declaration
public bool TryGetVariable(string name, out dynamic value)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of the variable. |
Object | value | Value of the variable. |
Returns
Type | Description |
---|---|
Boolean | A value indicating whether the variable was found. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |