2using System.Collections.Generic;
3using System.Reflection;
4using System.Threading.Tasks;
23 private readonly Dictionary<Type, bool> types =
new Dictionary<Type, bool>();
24 private readonly Dictionary<string, bool> isLabel =
new Dictionary<string, bool>();
25 private readonly
IVector vector;
27 private readonly
string name;
28 private readonly
string alias;
50 if (T is
null || T == LastType)
75 KeyValuePair<VariableReference, bool>[] Order,
ScriptNode Node)
77 return Find(this.vector, Offset, Top, Generic, Where,
Variables, Order, Node);
81 KeyValuePair<VariableReference, bool>[] Order,
ScriptNode Node)
89 if ((c = Order?.Length ?? 0) > 0)
91 List<IElement> Items =
new List<IElement>();
101 IComparer<IElement> Order2;
104 Order2 = ToPropertyOrder(Node, Order[0]);
107 IComparer<IElement>[] Orders =
new IComparer<IElement>[c];
109 for (i = 0; i < c; i++)
110 Orders[i] = ToPropertyOrder(Node, Order[i]);
123 if (Top !=
int.MaxValue)
131 return new PropertyOrder(Node, Order.Key.VariableName, Order.Value ? 1 : -1);
139 public Task
Update(
bool Lazy, IEnumerable<object> Objects)
141 return Task.CompletedTask;
144 private Exception InvalidOperation()
161 KeyValuePair<VariableReference, bool>[] Order,
ScriptNode Node)
163 throw this.InvalidOperation();
171 public Task
Insert(
bool Lazy,
object Object)
173 throw this.InvalidOperation();
197 get =>
string.IsNullOrEmpty(this.alias) ? this.name : this.alias;
208 string.Compare(this.name,
Name,
true) == 0 ||
209 string.Compare(this.alias,
Name,
true) == 0;
221 if (!this.isLabel.TryGetValue(Label, out
bool Result))
225 foreach (Type T
in this.types.Keys)
227 PropertyInfo PI = T.GetRuntimeProperty(Label);
231 FieldInfo FI = T.GetRuntimeField(Label);
235 Result = FI.IsPublic;
241 Result = PI.CanRead && PI.GetMethod.IsPublic;
246 this.isLabel[Label] = Result;
249 return Task.FromResult<
bool>(Result);
260 throw this.InvalidOperation();
270 throw InvalidOperation();
278 throw InvalidOperation();
290 throw new ArgumentException(
"Result Set lacks named columns.", nameof(ResultSet));
292 int Rows = ResultSet.
Rows;
293 int Columns = ResultSet.
Columns;
296 Dictionary<string, object> Object;
299 for (y = 0; y < Rows; y++)
301 Object =
new Dictionary<string, object>();
304 for (x = 0; x < Columns; x++)
Script runtime exception.
Class managing a script expression.
static IElement Encapsulate(object Value)
Encapsulates an object.
Base class for all nodes in a parsed script tree.
IElement GetElement(int Index)
Gets an element of the vector.
bool HasColumnNames
If the matrix has column names defined.
int Columns
Number of columns.
string[] ColumnNames
Contains optional column names.
Orders elements based on a sequence of comparers.
Orders elements based on values of a given property.
Creates a generalized representation of an object.
override Task< IElement > EvaluateAsync(IElement Argument, Variables Variables)
Evaluates the function.
Enumerator that only returns elements matching a set of conditions.
Enumerator that limits the return set to a maximum number of records.
Enumerator that skips a given number of result records.
Data Source defined by a vector.
VectorSource(string Name, string Alias, IVector Vector, ScriptNode Node)
Data Source defined by a vector.
Task< bool > DropIndex(string Name)
Drops an index from the source.
Task Update(bool Lazy, IEnumerable< object > Objects)
Updates a set of objects.
Task Insert(bool Lazy, object Object)
Inserts an object.
string TypeName
Name of corresponding type.
Task< bool > IsLabel(string Label)
Checks if the label is a label in the source.
static ObjectVector ToGenericObjectVector(ObjectMatrix ResultSet)
Converts an object matrix, with named columns, to a vector of objects ex nihilo.
string Name
Collection name or alias.
Task CreateIndex(string Name, string[] Fields)
Creates an index in the source.
Task< IResultSetEnumerator > Find(int Offset, int Top, bool Generic, ScriptNode Where, Variables Variables, KeyValuePair< VariableReference, bool >[] Order, ScriptNode Node)
Finds objects matching filter conditions in Where .
bool IsSource(string Name)
Checks if the name refers to the source.
Task DropCollection()
Drops the collection from the source.
string CollectionName
Name of corresponding collection.
Task< int?> FindDelete(bool Lazy, int Offset, int Top, ScriptNode Where, Variables Variables, KeyValuePair< VariableReference, bool >[] Order, ScriptNode Node)
Finds and Deletes a set of objects.
Task< bool > MoveNextAsync()
Advances the enumerator to the next element of the collection.
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.
Basic interface for vectors.
ICollection< IElement > VectorElements
An enumeration of vector elements.
Interface for result-set enumerators.
Interface for data sources that can be used in SQL statements.