2using System.Reflection;
3using System.Threading.Tasks;
42 return this.
Evaluate(Left, Middle, Right);
46 this.
Evaluate(Left, MiddleElement, Right);
67 return this.
Evaluate(Left, Middle, Right);
71 this.
Evaluate(Left, MiddleElement, Right);
90 Type Type = LeftValue.GetType();
92 PropertyInfo Property = Type.GetRuntimeProperty(Name);
93 if (!(Property is
null))
95 if (!Property.CanWrite)
97 else if (!Property.SetMethod.IsPublic)
101 Type = Property.PropertyType;
102 if (!Type.IsAssignableFrom(Right.GetType().GetTypeInfo()))
105 Property.SetValue(LeftValue, Right,
null);
110 FieldInfo Field = Type.GetRuntimeField(Name);
111 if (!(Field is
null))
117 Type = Field.FieldType;
118 if (!Type.IsAssignableFrom(Right.GetType().GetTypeInfo()))
121 Field.SetValue(Left, Right);
127 out ParameterInfo[] IndexArguments) &&
128 (IndexArguments?.Length ?? 0) == 1)
132 if (IndexArguments[0].ParameterType == typeof(
string))
133 Index =
new object[] { Name };
135 Index =
new object[] {
Expression.
ConvertTo(Name, IndexArguments[0].ParameterType,
this) };
137 Type = Property.PropertyType;
138 if (Type == typeof(
object))
140 else if (Type.IsAssignableFrom(Right.GetType().GetTypeInfo()))
141 Property.SetValue(LeftValue, Right, Index);
146 throw new ScriptRuntimeException(
"Member '" + Name +
"' not found on type '" + Type.FullName +
"'.",
this);
Script runtime exception.
Class managing a script expression.
static object ConvertTo(IElement Value, Type DesiredType, ScriptNode Node)
Tries to conevert an element value to a desired type.
ScriptNode RightOperand
Right operand.
ScriptNode LeftOperand
Left operand.
ScriptNode right
Right operand.
ScriptNode left
Left operand.
bool isAsync
If subtree is asynchroneous.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
int Start
Start position in script expression.
abstract IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
virtual Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
Base class for all ternary operators.
ScriptNode middle
Middle operand.
Dynamic member Assignment operator.
DynamicMemberAssignment(DynamicMember DynamicMember, ScriptNode Operand, int Start, int Length, Expression Expression)
Dynamic member Assignment operator.
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
IElement Evaluate(IElement Left, IElement Middle, IElement Right)
Performs scalar dynamic member assignment.
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
static bool TryGetIndexProperty(Type T, bool ForReading, bool ForWriting, out PropertyInfo PropertyInfo, out ParameterInfo[] Parameters)
Tries to get a one-dimensional index property of a Type.
Basic interface for all types of elements.
object AssociatedObjectValue
Associated object value.
ICollection< IElement > ChildElements
An enumeration of child elements. If the element is a scalar, this property will return null.
bool IsScalar
If the element represents a scalar value.