Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Waher.Script.Variables Class Reference

Collection of variables. More...

Inheritance diagram for Waher.Script.Variables:
Waher.Script.IContextVariables TAG.Simulator.ObjectModel.Events.EventVariables Waher.Script.Persistence.SQL.ObjectProperties

Public Member Functions

 Variables (params Variable[] Variables)
 Collection of variables. More...
 
virtual bool TryGetVariable (string Name, out Variable Variable)
 Tries to get a variable object, given its name. More...
 
virtual bool ContainsVariable (string Name)
 If the collection contains a variable with a given name. More...
 
virtual Variable Add (string Name, object Value)
 Adds a variable to the collection. More...
 
virtual bool Remove (string VariableName)
 Removes a varaiable from the collection. More...
 
virtual void Clear ()
 Removes all variables from the collection. More...
 
virtual void Push ()
 Pushes the current set of variables to the stack. This state is restored by calling Pop. Each call to this method must be followed by exactly one call to Pop. More...
 
virtual void Pop ()
 Pops a previously stored set of variables from the stack. Variables are stored on the stack by calling Push. More...
 
void Lock ()
 Locks the collection. The collection is by default thread safe. But if longer transactions require unique access, this method can be used to aquire such unique access. This works, as long as all callers that affect the corresponding state call this method also. More...
 
Task LockAsync ()
 Locks the collection. The collection is by default thread safe. But if longer transactions require unique access, this method can be used to aquire such unique access. This works, as long as all callers that affect the corresponding state call this method also. More...
 
void Lock (int Timeout)
 Locks the collection. The collection is by default thread safe. But if longer transactions require unique access, this method can be used to aquire such unique access. This works, as long as all callers that affect the corresponding state call this method also. More...
 
async Task LockAsync (int Timeout)
 Locks the collection. The collection is by default thread safe. But if longer transactions require unique access, this method can be used to aquire such unique access. This works, as long as all callers that affect the corresponding state call this method also. More...
 
void Release ()
 Releases the collection, previously locked through a call to Lock(). More...
 
IEnumerator< VariableGetEnumerator ()
 Returns an enumerator that iterates through a collection. More...
 
void CopyTo (Variables Variables)
 Copies available variables to another variable collection. More...
 
void Abort ()
 Aborts the execution of script using this collection of variables. More...
 
void CancelAbort ()
 Allows new script to be evaluated using this collection of variables. More...
 
void Preview (Expression Expression, IElement Result)
 Reports a preview of the final result. More...
 
void Status (Expression Expression, string Result)
 Reports current status of execution. More...
 

Protected Attributes

Dictionary< string, Variablevariables = new Dictionary<string, Variable>()
 Internal set of variables. More...
 

Properties

object this[string Name] [get, set]
 Access to variable values through the use of their names. More...
 
TextWriter ConsoleOut [get, set]
 Console out interface. Can be used by functions and script to output data to the console. More...
 
IContextVariables ContextVariables [get, set]
 Variables available during the current context. More...
 
ValuePrinter Printer [get, set]
 Delegate that converts values to strings for (implicit) printing. Default is null, which will call the Object.ToString() method to convert the value to a string. More...
 
Variable[] AvailableVariables [get]
 Returns an array of available variables. More...
 
bool HandlesPreview [get]
 If previews are desired. More...
 
bool HandlesStatus [get]
 If status messages are desired. More...
 

Events

PreviewEventHandler OnPreview
 Event raised when there is a new value to preview. More...
 
StatusEventHandler OnStatus = null
 Event raised when a status message has been reported. More...
 

Detailed Description

Collection of variables.

Definition at line 24 of file Variables.cs.

Constructor & Destructor Documentation

◆ Variables()

Waher.Script.Variables.Variables ( params Variable[]  Variables)

Collection of variables.

Definition at line 40 of file Variables.cs.

Member Function Documentation

◆ Abort()

void Waher.Script.Variables.Abort ( )

Aborts the execution of script using this collection of variables.

Definition at line 415 of file Variables.cs.

◆ Add()

virtual Variable Waher.Script.Variables.Add ( string  Name,
object  Value 
)
virtual

Adds a variable to the collection.

Parameters
NameVariable name.
ValueAssociated variable object value.
Returns
Reference to variable that was added.

Implements Waher.Script.IContextVariables.

Reimplemented in Waher.Script.Persistence.SQL.ObjectProperties.

Definition at line 122 of file Variables.cs.

◆ CancelAbort()

void Waher.Script.Variables.CancelAbort ( )

Allows new script to be evaluated using this collection of variables.

Definition at line 423 of file Variables.cs.

◆ Clear()

virtual void Waher.Script.Variables.Clear ( )
virtual

Removes all variables from the collection.

Definition at line 163 of file Variables.cs.

◆ ContainsVariable()

virtual bool Waher.Script.Variables.ContainsVariable ( string  Name)
virtual

If the collection contains a variable with a given name.

Parameters
NameVariable name.
Returns
If a variable with that name exists.

Implements Waher.Script.IContextVariables.

Reimplemented in TAG.Simulator.ObjectModel.Events.EventVariables, and Waher.Script.Persistence.SQL.ObjectProperties.

Definition at line 76 of file Variables.cs.

◆ CopyTo()

void Waher.Script.Variables.CopyTo ( Variables  Variables)

Copies available variables to another variable collection.

Parameters
VariablesVariable collection to copy variables to.

Definition at line 400 of file Variables.cs.

◆ GetEnumerator()

IEnumerator< Variable > Waher.Script.Variables.GetEnumerator ( )

Returns an enumerator that iterates through a collection.

Returns
Enumerator object.

Definition at line 341 of file Variables.cs.

◆ Lock() [1/2]

void Waher.Script.Variables.Lock ( )

Locks the collection. The collection is by default thread safe. But if longer transactions require unique access, this method can be used to aquire such unique access. This works, as long as all callers that affect the corresponding state call this method also.

Each successful call to this method must be followed by exacty one call to Release.

Exceptions
TimeoutExceptionIf access to the collection was not granted in the alotted time

Definition at line 252 of file Variables.cs.

◆ Lock() [2/2]

void Waher.Script.Variables.Lock ( int  Timeout)

Locks the collection. The collection is by default thread safe. But if longer transactions require unique access, this method can be used to aquire such unique access. This works, as long as all callers that affect the corresponding state call this method also.

Each successful call to this method must be followed by exacty one call to Release.

Parameters
TimeoutTimeout, in milliseconds. Default timeout is 30000 milliseconds (30 s).
Exceptions
TimeoutExceptionIf access to the collection was not granted in the alotted time

Definition at line 280 of file Variables.cs.

◆ LockAsync() [1/2]

Task Waher.Script.Variables.LockAsync ( )

Locks the collection. The collection is by default thread safe. But if longer transactions require unique access, this method can be used to aquire such unique access. This works, as long as all callers that affect the corresponding state call this method also.

Each successful call to this method must be followed by exacty one call to Release.

Exceptions
TimeoutExceptionIf access to the collection was not granted in the alotted time

Definition at line 265 of file Variables.cs.

◆ LockAsync() [2/2]

async Task Waher.Script.Variables.LockAsync ( int  Timeout)

Locks the collection. The collection is by default thread safe. But if longer transactions require unique access, this method can be used to aquire such unique access. This works, as long as all callers that affect the corresponding state call this method also.

Each successful call to this method must be followed by exacty one call to Release.

Parameters
TimeoutTimeout, in milliseconds. Default timeout is 30000 milliseconds (30 s).
Exceptions
TimeoutExceptionIf access to the collection was not granted in the alotted time

Definition at line 294 of file Variables.cs.

◆ Pop()

virtual void Waher.Script.Variables.Pop ( )
virtual

Pops a previously stored set of variables from the stack. Variables are stored on the stack by calling Push.

Definition at line 202 of file Variables.cs.

◆ Preview()

void Waher.Script.Variables.Preview ( Expression  Expression,
IElement  Result 
)

Reports a preview of the final result.

Parameters
ExpressionExpression being executed.
ResultPreview

Definition at line 455 of file Variables.cs.

◆ Push()

virtual void Waher.Script.Variables.Push ( )
virtual

Pushes the current set of variables to the stack. This state is restored by calling Pop. Each call to this method must be followed by exactly one call to Pop.

Definition at line 180 of file Variables.cs.

◆ Release()

void Waher.Script.Variables.Release ( )

Releases the collection, previously locked through a call to Lock().

Definition at line 308 of file Variables.cs.

◆ Remove()

virtual bool Waher.Script.Variables.Remove ( string  VariableName)
virtual

Removes a varaiable from the collection.

Parameters
VariableNameName of variable.
Returns
If the variable was found and removed.

Reimplemented in TAG.Simulator.ObjectModel.Events.EventVariables.

Definition at line 147 of file Variables.cs.

◆ Status()

void Waher.Script.Variables.Status ( Expression  Expression,
string  Result 
)

Reports current status of execution.

Parameters
ExpressionExpression.
ResultStatus Message

Definition at line 481 of file Variables.cs.

◆ TryGetVariable()

virtual bool Waher.Script.Variables.TryGetVariable ( string  Name,
out Variable Variable   
)
virtual

Tries to get a variable object, given its name.

Parameters
NameVariable name.
VariableVariable, if found, or null otherwise.
Returns
If a variable with the corresponding name was found.

Implements Waher.Script.IContextVariables.

Reimplemented in Waher.Script.Persistence.SQL.ObjectProperties.

Definition at line 52 of file Variables.cs.

Member Data Documentation

◆ variables

Dictionary<string, Variable> Waher.Script.Variables.variables = new Dictionary<string, Variable>()
protected

Internal set of variables.

Definition at line 29 of file Variables.cs.

Property Documentation

◆ AvailableVariables

Variable [] Waher.Script.Variables.AvailableVariables
get

Returns an array of available variables.

Definition at line 316 of file Variables.cs.

◆ ConsoleOut

TextWriter Waher.Script.Variables.ConsoleOut
getset

Console out interface. Can be used by functions and script to output data to the console.

Definition at line 218 of file Variables.cs.

◆ ContextVariables

IContextVariables Waher.Script.Variables.ContextVariables
getset

Variables available during the current context.

Definition at line 227 of file Variables.cs.

◆ HandlesPreview

bool Waher.Script.Variables.HandlesPreview
get

If previews are desired.

Definition at line 436 of file Variables.cs.

◆ HandlesStatus

bool Waher.Script.Variables.HandlesStatus
get

If status messages are desired.

Definition at line 500 of file Variables.cs.

◆ Printer

ValuePrinter Waher.Script.Variables.Printer
getset

Delegate that converts values to strings for (implicit) printing. Default is null, which will call the Object.ToString() method to convert the value to a string.

Definition at line 237 of file Variables.cs.

◆ this[string Name]

object Waher.Script.Variables.this[string Name]
getset

Access to variable values through the use of their names.

Parameters
NameVariable name.
Returns
Associated variable object value.

Definition at line 100 of file Variables.cs.

Event Documentation

◆ OnPreview

PreviewEventHandler Waher.Script.Variables.OnPreview

Event raised when there is a new value to preview.

Definition at line 431 of file Variables.cs.

◆ OnStatus

StatusEventHandler Waher.Script.Variables.OnStatus = null

Event raised when a status message has been reported.

Definition at line 508 of file Variables.cs.


The documentation for this class was generated from the following file: