2using System.Reflection;
3using System.Threading.Tasks;
91 Type Type = LeftValue.GetType();
93 PropertyInfo Property = Type.GetRuntimeProperty(Name);
94 if (!(Property is
null))
96 if (!Property.CanWrite)
98 else if (!Property.SetMethod.IsPublic)
102 Type = Property.PropertyType;
103 if (!Type.GetTypeInfo().IsAssignableFrom(Right.GetType().GetTypeInfo()))
106 Property.SetValue(LeftValue, Right,
null);
111 FieldInfo Field = Type.GetRuntimeField(Name);
112 if (!(Field is
null))
118 Type = Field.FieldType;
119 if (!Type.GetTypeInfo().IsAssignableFrom(Right.GetType().GetTypeInfo()))
122 Field.SetValue(Left, Right);
129 Type = Property.PropertyType;
130 if (Type == typeof(
object))
132 else if (Type.GetTypeInfo().IsAssignableFrom(Right.GetType().GetTypeInfo()))
133 Property.SetValue(LeftValue, Right,
new string[] { Name });
135 Property.SetValue(LeftValue,
Expression.
ConvertTo(Right, Type,
this),
new string[] { Name });
138 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, Variables Variables)
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.