80 string s = Left.DefaultVariableName;
83 else if (s == Right.DefaultVariableName)
118 bool RecalcIsAsync =
false;
121 if (!(this.left is
null))
123 b = !Callback(this.left, out NewNode, State);
124 if (!(NewNode is
null))
129 RecalcIsAsync =
true;
132 if (b || (Order ==
SearchMethod.TreeOrder && !
this.left.ForAllChildNodes(Callback, State, Order)))
141 if (!(this.right is
null))
143 b = !Callback(this.right, out NewNode, State);
144 if (!(NewNode is
null))
146 this.right = NewNode;
149 RecalcIsAsync =
true;
152 if (b || (Order ==
SearchMethod.TreeOrder && !
this.right.ForAllChildNodes(Callback, State, Order)))
188 int Result = base.GetHashCode();
211 lock (customBinaryOperators)
214 customBinaryOperators.TryGetValue(Name, out Dictionary<Type, Dictionary<Type, IBinaryOperator>> ByLeftType) &&
215 ByLeftType.TryGetValue(LeftType, out Dictionary<Type, IBinaryOperator> ByRightType) &&
216 ByRightType.TryGetValue(RightType, out CustomOperator);
219 if (!(CustomOperator is
null))
229 if (!(Result is
null))
232 Result = OperatorMethod.
EvaluateAsync(RightType,
null, Arguments,
null).Result;
234 if (!(Result is
null))
243 lock (customBinaryOperators)
245 if (!customBinaryOperators.TryGetValue(Name, out Dictionary<Type, Dictionary<Type, IBinaryOperator>> ByLeftType))
247 ByLeftType =
new Dictionary<Type, Dictionary<Type, IBinaryOperator>>();
248 customBinaryOperators[Name] = ByLeftType;
251 if (!ByLeftType.TryGetValue(LeftType, out Dictionary<Type, IBinaryOperator> ByRightType))
253 ByRightType =
new Dictionary<Type, IBinaryOperator>();
254 ByLeftType[LeftType] = ByRightType;
257 ByRightType[RightType] = CustomOperator;
260 if (!(CustomOperator is
null))
267 private static readonly Dictionary<string, Dictionary<Type, Dictionary<Type, IBinaryOperator>>>
268 customBinaryOperators =
new Dictionary<string, Dictionary<Type, Dictionary<Type, IBinaryOperator>>>();
Static class that dynamically manages types and interfaces available in the runtime environment.
Class managing a script expression.
Information about a binary operation for use with custom binary operators.
Base class for all binary operators.
ScriptNode RightOperand
Right operand.
virtual void CalcIsAsync()
Recalculates if operator is asynchronous or not.
ScriptNode LeftOperand
Left operand.
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
ScriptNode right
Right operand.
ScriptNode left
Left operand.
override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
override int GetHashCode()
override bool Equals(object obj)
static IElement EvaluateNamedOperator(string Name, IElement Left, IElement Right, ScriptNode Node)
Evaluates a named operator available in code-behind.
BinaryOperator(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
Base class for all binary operators.
bool isAsync
If subtree is asynchroneous.
virtual string DefaultVariableName
Default variable name, if any, null otherwise.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
static bool AreEqual(ScriptNode S1, ScriptNode S2)
Compares if two script nodes are equal.
int Start
Start position in script expression.
virtual bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
void SetParent(ScriptNode Parent)
Sets the parent node. Can only be used when expression is being parsed or created.
Named method call operator.
override async Task< IElement > EvaluateAsync(IElement Operand, Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Interface for binary operations.
Interface for custom binary operators.
IElement Evaluate(IBinaryOperation Operation, ScriptNode Node)
Evaluates the custom binary operator.
Basic interface for all types of elements.
object AssociatedObjectValue
Associated object value.
Base interface for lambda expressions.
delegate bool ScriptNodeEventHandler(ScriptNode Node, out ScriptNode NewNode, object State)
Delegate for ScriptNode callback methods.
SearchMethod
Method to traverse the expression structure