3using System.Reflection;
4using System.Threading.Tasks;
66 if (this.alias is
null)
69 Alias = Ref.VariableName;
74 return GetDataSource(Ref2, Alias,
Variables);
78 return GetDataSource(
string.Empty, Alias, await AsyncSource.EvaluateAsync(
Variables),
this.source);
96 else if (Obj is Type T)
106 else if (Obj is
string s)
110 if (NamedDataSource is
null)
113 return NamedDataSource;
119 else if (Obj is XmlDocument Doc)
120 return new XmlSource(Name, Alias, Doc, Source);
121 else if (Obj is XmlNode N)
122 return new XmlSource(Name, Alias, N, Source);
131 lock (namedDataSources)
133 if (namedDataSources.TryGetValue(Name, out Result))
139 lock (namedDataSources)
141 namedDataSources[Name] = Result;
147 private static readonly Dictionary<string, INamedDataSource> namedDataSources =
new Dictionary<string, INamedDataSource>();
154 return GetDataSource(Name, Alias, v.ValueElement, Source);
157 return GetDataSource(Name, Alias, ValueElement, Source);
161 if (QualifiedNames.Length == 1)
171 Type TypeWithCollection =
null;
172 bool CollectionUnique =
true;
174 foreach (
string QualifiedName
in QualifiedNames)
180 TypeInfo TI = T.GetTypeInfo();
185 if (TypeWithCollection is
null)
186 TypeWithCollection = T;
189 CollectionUnique =
false;
191 if (TypesWithCollectionNames is
null)
195 new KeyValuePair<string, object>(
"Type " + Nr.ToString(), TypeWithCollection.FullName)
201 TypesWithCollectionNames.
Add(
new KeyValuePair<string, object>(Nr.ToString(), T.FullName));
207 if (TypeWithCollection is
null)
209 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.",
210 Name,
string.Empty,
"DBOpt");
214 if (CollectionUnique)
216 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.",
217 Name, TypeWithCollection.FullName,
"DBOpt");
219 return new TypeSource(TypeWithCollection, Alias);
223 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.",
224 Name,
string.Empty,
"DBOpt", TypesWithCollectionNames.
ToArray());
232 if (NamedDataSource is
null)
235 return NamedDataSource;
259 if (!(this.source is
null))
261 b = !Callback(this.source, out NewNode, State);
262 if (!(NewNode is
null))
264 this.source = NewNode;
268 if (b || (Order ==
SearchMethod.TreeOrder && !
this.source.ForAllChildNodes(Callback, State, Order)))
272 if (!(this.alias is
null))
274 b = !Callback(this.alias, out NewNode, State);
275 if (!(NewNode is
null))
277 this.alias = NewNode;
281 if (b || (Order ==
SearchMethod.TreeOrder && !
this.alias.ForAllChildNodes(Callback, State, Order)))
309 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.
A chunked list is a linked list of chunks of objects of type T .
void Add(T Item)
Adds an item to the collection.
T[] ToArray()
Returns an array containing all elements of the collection.
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 object[] NoParameters
Contains an empty array of parameter values.
static bool TryGetQualifiedNames(string UnqualifiedName, out string[] QualifiedNames)
Gets an array (possibly null) of qualified names relating to an unqualified name.
static ConstructorInfo GetDefaultConstructor(Type Type)
Gets the default constructor of a type, if one exists.
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 or created.
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.
Interface for named 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