2using System.Collections;
3using System.Collections.Generic;
4using System.Reflection;
5using System.Threading.Tasks;
22 private static readonly MethodInfo findMethodGeneric = GetFindMethod();
42 private static MethodInfo GetFindMethod()
45 foreach (MethodInfo MI
in T.GetTypeInfo().GetDeclaredMethods(
"Find"))
47 ParameterInfo[] P = MI.GetParameters();
49 P[0].ParameterType != typeof(
int) ||
50 P[1].ParameterType != typeof(
int) ||
51 P[2].ParameterType != typeof(
Filter) ||
52 P[3].ParameterType != typeof(
string[]))
111 if (!(
Arguments[0].AssociatedObjectValue is Type T))
116 object FilterObj =
Arguments[3].AssociatedObjectValue;
120 string[] SortOrder =
new string[c];
122 for (i = 0; i < c; i++)
125 if (
Filter is
null && !(FilterObj is
null))
131 MethodInfo MI = findMethodGeneric.MakeGenericMethod(
new Type[] { T });
132 object Result = MI.Invoke(
null,
new object[] { Offset, MaxCount,
Filter, SortOrder });
135 if (Result is IEnumerable E)
137 LinkedList<IElement> Elements =
new LinkedList<IElement>();
138 IEnumerator e = E.GetEnumerator();
157 else if (Node is
Or Or)
162 else if (Node is Operators.Dual.And And2)
165 await
this.ConvertAsync(And2.RightOperand,
Variables));
167 else if (Node is Operators.Dual.Or Or2)
170 await
this.ConvertAsync(Or2.RightOperand,
Variables));
176 KeyValuePair<string, object> P = await this.CheckBinaryOperator(EQ,
Variables);
181 KeyValuePair<string, object> P = await this.CheckBinaryOperator(NEQ,
Variables);
186 KeyValuePair<string, object> P = await this.CheckBinaryOperator(LT,
Variables);
191 KeyValuePair<string, object> P = await this.CheckBinaryOperator(GT,
Variables);
196 KeyValuePair<string, object> P = await this.CheckBinaryOperator(LTE,
Variables);
201 KeyValuePair<string, object> P = await this.CheckBinaryOperator(GTE,
Variables);
207 throw new ScriptRuntimeException(
"Middle operands in ternary filter operators need to be a variable references, as they refer to field names.",
this);
209 string FieldName = v.VariableName;
227 else if (Node is
Like)
246 throw new ScriptRuntimeException(
"Left operands in binary filter operators need to be a variable references, as they refer to field names.",
this);
248 return new KeyValuePair<string, object>(v.VariableName, (await Operator.RightOperand.EvaluateAsync(
Variables)).AssociatedObjectValue);
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static string WildcardToRegex(string s, string Wildcard)
Converts a wildcard string to a regular expression string.
This filter selects objects that conform to all child-filters provided.
This filter selects objects that have a named field equal to a given value.
This filter selects objects that have a named field greater or equal to a given value.
This filter selects objects that have a named field greater than a given value.
This filter selects objects that have a named field lesser or equal to a given value.
This filter selects objects that have a named field lesser than a given value.
This filter selects objects that have a named field matching a given regular expression.
This filter selects objects that have a named field not equal to a given value.
Base class for all filter classes.
This filter selects objects that does not conform to the child-filter provided.
This filter selects objects that conform to any of the child-filters provided.
Script runtime exception.
Class managing a script expression.
ScriptNode Root
Root script node.
static IElement Encapsulate(object Value)
Encapsulates an object.
static double ToDouble(object Object)
Converts an object to a double value.
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Base class for all binary operators.
ScriptNode RightOperand
Right operand.
ScriptNode LeftOperand
Left operand.
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
static async Task< object > WaitPossibleTask(object Result)
Waits for any asynchronous process to terminate.
Expression Expression
Expression of which the node is a part.
int Start
Start position in script expression.
virtual Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
ScriptNode MiddleOperand
Middle operand.
ScriptNode Operand
Operand.
Represents a variable reference.
Greater Than Or Equal To.
bool LeftInclusive
If the value specified by BinaryOperator.LeftOperand is included in the range.
bool RightInclusive
If the value specified by BinaryOperator.RightOperand is included in the range.
Finds objects in the object database.
override string[] DefaultArgumentNames
Default Argument names
override string FunctionName
Name of the function
override async Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
Evaluates the function.
FindObjects(ScriptNode Type, ScriptNode Offset, ScriptNode MaxCount, ScriptNode Filter, ScriptNode SortOrder, int Start, int Length, Expression Expression)
Finds object in the object database.
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
Basic interface for all types of elements.
object AssociatedObjectValue
Associated object value.
Basic interface for vectors.
int Dimension
Dimension of vector.
IElement GetElement(int Index)
Gets an element of the vector.
ArgumentType
Type of parameter used in a function definition or a lambda definition.