Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LambdaEvaluator.cs
1using System.Threading.Tasks;
2using Waher.Script;
6
8{
13 {
14 private LambdaDefinition lambda;
15 private ObjectProperties variables;
16
21 {
22 }
23
29 public async Task Prepare(string Definition)
30 {
31 Expression Exp = new Expression(Definition);
32 this.lambda = await Exp.EvaluateAsync(new Variables()) as LambdaDefinition;
33 }
34
40 public async Task<object> Evaluate(object Instance)
41 {
42 if (!(this.lambda is null))
43 {
44 if (this.variables is null)
45 this.variables = new ObjectProperties(Instance, new Variables());
46 else
47 this.variables.Object = Instance;
48
49 IElement E = await this.lambda.EvaluateAsync(new IElement[] { Expression.Encapsulate(Instance) }, this.variables);
50
51 return E.AssociatedObjectValue;
52 }
53 else
54 return null;
55 }
56 }
57}
Evaluates property values where properties are defined as script expressions.
LambdaEvaluator()
Evaluates property values where properties are defined as script expressions.
async Task< object > Evaluate(object Instance)
Evaluates the parsed definition, on an object instance.
async Task Prepare(string Definition)
Parses a property definition.
Class managing a script expression.
Definition: Expression.cs:39
async Task< object > EvaluateAsync(Variables Variables)
Evaluates the expression, using the variables provided in the Variables collection....
Definition: Expression.cs:4275
static IElement Encapsulate(object Value)
Encapsulates an object.
Definition: Expression.cs:4955
override Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:33