/// <summary> /// Finds objects matching filter conditions in <paramref name="Where"/>. /// </summary> /// <param name="Offset">Offset at which to return elements.</param> /// <param name="Top">Maximum number of elements to return.</param> /// <param name="Where">Filter conditions.</param> /// <param name="Variables">Current set of variables.</param> /// <param name="Order">Order at which to order the result set.</param> /// <param name="Node">Script node performing the evaluation.</param> /// <returns>Enumerator.</returns> public async Task <IResultSetEnumerator> Find(int Offset, int Top, ScriptNode Where, Variables Variables, KeyValuePair <VariableReference, bool>[] Order, ScriptNode Node) { object[] FindParameters = new object[] { Offset, Top, Convert(Where, Variables, this.Name), Convert(Order) }; object Obj = FindMethod.MakeGenericMethod(this.type).Invoke(null, FindParameters); if (!(Obj is Task Task)) { throw new ScriptRuntimeException("Unexpected response.", Node); } await Task; PropertyInfo PI = Task.GetType().GetRuntimeProperty("Result"); if (PI is null) { throw new ScriptRuntimeException("Unexpected response.", Node); } Obj = PI.GetValue(Task); if (!(Obj is IEnumerable Enumerable)) { throw new ScriptRuntimeException("Unexpected response.", Node); } return(new SynchEnumerator(Enumerable.GetEnumerator())); }
internal static IEnumerator Find(Type T, int Offset, int Top, ScriptNode Where, Variables Variables, string[] Order, ScriptNode Node) { object[] FindParameters = new object[] { Offset, Top, Convert(Where, Variables), Order }; object Obj = FindMethod.MakeGenericMethod(T).Invoke(null, FindParameters); if (!(Obj is Task Task)) { throw new ScriptRuntimeException("Unexpected response.", Node); } PropertyInfo PI = Task.GetType().GetRuntimeProperty("Result"); if (PI == null) { throw new ScriptRuntimeException("Unexpected response.", Node); } Obj = PI.GetValue(Task); if (!(Obj is IEnumerable Enumerable)) { throw new ScriptRuntimeException("Unexpected response.", Node); } return(Enumerable.GetEnumerator()); }