Class ScriptScopeWrapper
Represents a wrapper for the Microsoft.Scripting.Hosting.ScriptScope class. ExternalVariables returns all variables that where added by SetVariable(string, object).
public class ScriptScopeWrapper
- Inheritance
-
ScriptScopeWrapper
- Inherited Members
Properties
ExternalVariables
Gets the variables that were added by SetVariable(string, object).
public IReadOnlyDictionary<string, object> ExternalVariables { get; }
Property Value
Methods
ContainsVariable(string)
Determines if this context or any outer scope contains the defined name.
public bool ContainsVariable(string name)
Parameters
name
stringName of the variable.
Returns
- bool
True when a variable named
name
exists, otherwise false.
GetItems()
Gets all variables.
public IEnumerable<KeyValuePair<string, dynamic>> GetItems()
Returns
- IEnumerable<KeyValuePair<string, object>>
All variables in the scope.
GetVariable(string)
Gets a value stored in the scope under the given name.
public dynamic GetVariable(string name)
Parameters
name
stringName of the variable.
Returns
- dynamic
Value of the variable.
Exceptions
- MissingMemberException
Thrown when the specified name is not defined in the scope.
- ArgumentNullException
Thrown when
name
is null.
GetVariableNames()
Gets all names of all variables.
public IEnumerable<string> GetVariableNames()
Returns
- IEnumerable<string>
Names of variables.
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.
public T GetVariable<T>(string name)
Parameters
name
stringName of the variable.
Returns
- T
The converted value of the variable.
Type Parameters
T
Type to convert the variable value.
RemoveVariable(string)
Removes the variable of the given name from this scope.
public bool RemoveVariable(string name)
Parameters
name
stringName of the variable.
Returns
- bool
true if the value existed in the scope before it has been removed.
Exceptions
- ArgumentNullException
Thrown when
name
is null.
SetVariable(string, object)
Sets the name to the specified value.
public void SetVariable(string name, object value)
Parameters
Exceptions
- ArgumentNullException
Thrown when
name
is null.
TryGetVariable(string, out dynamic)
Tries to get a value stored in the scope under the given name.
public bool TryGetVariable(string name, out dynamic value)
Parameters
name
stringName of the variable.
value
dynamicValue of the variable.
Returns
- bool
A value indicating whether the variable was found.
Exceptions
- ArgumentNullException
Thrown when
name
is null.