2using System.Collections.Generic;
3using System.Reflection;
4using System.Threading.Tasks;
65 if (this.alias is
null)
68 Alias = Ref.VariableName;
73 return GetDataSource(Ref2, Alias,
Variables);
77 return GetDataSource(
string.Empty, Alias, await AsyncSource.EvaluateAsync(
Variables),
this.source);
95 else if (Obj is
string s)
101 else if (Obj is XmlDocument Doc)
102 return new XmlSource(Name, Alias, Doc, Source);
103 else if (Obj is XmlNode N)
104 return new XmlSource(Name, Alias, N, Source);
116 return GetDataSource(Name, Alias, v.ValueElement, Source);
119 return GetDataSource(Name, Alias, ValueElement, Source);
123 if (QualifiedNames.Length == 1)
132 List<KeyValuePair<string, object>> TypesWithCollectionNames =
null;
133 Type TypeWithCollection =
null;
134 bool CollectionUnique =
true;
136 foreach (
string QualifiedName
in QualifiedNames)
142 TypeInfo TI = T.GetTypeInfo();
147 if (TypeWithCollection is
null)
148 TypeWithCollection = T;
151 CollectionUnique =
false;
153 if (TypesWithCollectionNames is
null)
155 TypesWithCollectionNames =
new List<KeyValuePair<string, object>>
157 new KeyValuePair<string, object>(
"Type " + Nr.ToString(), TypeWithCollection.FullName)
163 TypesWithCollectionNames.Add(
new KeyValuePair<string, object>(Nr.ToString(), T.FullName));
169 if (TypeWithCollection is
null)
171 Log.
Warning(
"A collection was referenced using a relative type name. The type does not have a collection name defined. To avoid confusion, reference the collection name as a string constant instead of a variable reference.",
172 Name,
string.Empty,
"DBOpt");
176 if (CollectionUnique)
178 Log.
Warning(
"A collection was referenced using a relative type name. Multiple types are available with the same relative type name, but only one had a collection name defined for it. Using this type. Use fully.qualified type names to avoid confusion.",
179 Name, TypeWithCollection.FullName,
"DBOpt");
181 return new TypeSource(TypeWithCollection, Alias);
185 Log.
Error(
"A collection was referenced using a relative type name. Multiple types are available with the same relative type name and with collection names. Use fully.qualified type names to avoid confusion.",
186 Name,
string.Empty,
"DBOpt", TypesWithCollectionNames.ToArray());
216 if (!(this.source is
null))
218 b = !Callback(this.source, out NewNode, State);
219 if (!(NewNode is
null))
221 this.source = NewNode;
225 if (b || (Order ==
SearchMethod.TreeOrder && !
this.source.ForAllChildNodes(Callback, State, Order)))
229 if (!(this.alias is
null))
231 b = !Callback(this.alias, out NewNode, State);
232 if (!(NewNode is
null))
234 this.alias = NewNode;
238 if (b || (Order ==
SearchMethod.TreeOrder && !
this.alias.ForAllChildNodes(Callback, State, Order)))
266 int Result = base.GetHashCode();
Static class managing the application event log. Applications and services log events on this static ...
static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an error event.
This attribute defines the name of the collection that will house objects of this type.
Static class that dynamically manages types and interfaces available in the runtime environment.
static Type GetType(string FullName)
Gets a type, given its full name.
static bool TryGetQualifiedNames(string UnqualifiedName, out string[] QualifiedNames)
Gets an array (possibly null) of qualified names relating to an unqualified name.
Script runtime exception.
Class managing a script expression.
static bool TryGetConstant(string Name, Variables Variables, out IElement ValueElement)
Tries to get a constant value, given its name.
string VariableName
Variable Name.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
override string ToString()
static bool AreEqual(ScriptNode S1, ScriptNode S2)
Compares if two script nodes are equal.
int Start
Start position in script expression.
void SetParent(ScriptNode Parent)
Sets the parent node. Can only be used when expression is being parsed.
virtual Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
Represents a variable reference.
bool HasColumnNames
If the matrix has column names defined.
ToMatrix(ScriptNode Operand, bool NullCheck, int Start, int Length, Expression Expression)
To-Matrix operator.
Abstract base class for source definitions
Direct reference to a data source.
override async Task< IDataSource > GetSource(Variables Variables)
Gets the actual data source, from its definition.
override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
override bool Equals(object obj)
SourceReference(ScriptNode Source, int Start, int Length, Expression Expression)
Direct reference to a data source.
override int GetHashCode()
SourceReference(ScriptNode Source, ScriptNode Alias, int Start, int Length, Expression Expression)
Direct reference to a data source.
Data Source defined by a collection name
Data Source defined by a type definition
Data Source defined by a vector.
static ObjectVector ToGenericObjectVector(ObjectMatrix ResultSet)
Converts an object matrix, with named columns, to a vector of objects ex nihilo.
Data Source defined by XML.
Contains information about a variable.
virtual bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.
Basic interface for all types of elements.
object AssociatedObjectValue
Associated object value.
Basic interface for vectors.
Interface for script nodes with asynchronous evaluation
Interface for objects that can be converted into matrices.
Interface for data sources that can be used in SQL statements.
delegate bool ScriptNodeEventHandler(ScriptNode Node, out ScriptNode NewNode, object State)
Delegate for ScriptNode callback methods.
SearchMethod
Method to traverse the expression structure