2using System.Reflection;
3using System.Threading.Tasks;
17 private readonly
string name;
36 public string Name => this.name;
70 Type Type = LeftValue.GetType();
72 lock (this.synchObject)
74 if (Type != this.type)
77 this.property = Type.GetRuntimeProperty(this.name);
78 if (!(this.property is
null))
81 this.nameIndex =
null;
83 if (!this.property.CanWrite)
85 else if (!this.property.SetMethod.IsPublic)
90 this.field = Type.GetRuntimeField(this.name);
91 if (!(this.field is
null))
93 this.nameIndex =
null;
95 if (!this.field.IsPublic)
102 if (this.nameIndex is
null)
103 this.nameIndex =
new string[] { this.name };
106 this.nameIndex =
null;
111 if (!(this.property is
null))
113 Type = this.
property.PropertyType;
114 if (Type == typeof(
object))
116 else if (Type.GetTypeInfo().IsAssignableFrom(Right.GetType().GetTypeInfo()))
117 this.
property.SetValue(LeftValue, Right, this.nameIndex);
119 this.
property.SetValue(LeftValue,
Expression.
ConvertTo(Right, Type,
this),
this.nameIndex);
121 else if (!(this.field is
null))
123 Type = this.field.FieldType;
124 if (!Type.GetTypeInfo().IsAssignableFrom(Right.GetType().GetTypeInfo()))
127 this.field.SetValue(Left, Right);
130 throw new ScriptRuntimeException(
"Member '" + this.name +
"' not found on type '" + Type.FullName +
"'.",
this);
136 private Type type =
null;
137 private PropertyInfo
property =
null;
138 private FieldInfo field =
null;
139 private string[] nameIndex =
null;
140 private readonly
object synchObject =
new object();
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.
Base class for all binary operators.
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 ...
Named member Assignment operator.
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
NamedMemberAssignment(NamedMember NamedMember, ScriptNode Operand, int Start, int Length, Expression Expression)
Named member Assignment operator.
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
string Name
Name of method.
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.