Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DropCollection.cs
1using System;
2using System.Threading.Tasks;
6
8{
13 {
14 private SourceDefinition source;
15
24 : base(Start, Length, Expression)
25 {
26 this.source = Source;
27 this.source?.SetParent(this);
28 }
29
34 public override bool IsAsynchronous => true;
35
42 {
43 return this.EvaluateAsync(Variables).Result;
44 }
45
52 public override async Task<IElement> EvaluateAsync(Variables Variables)
53 {
54 IDataSource Source = await this.source.GetSource(Variables);
55 await Source.DropCollection();
56 return ObjectValue.Null;
57 }
58
66 public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
67 {
68 if (Order == SearchMethod.DepthFirst)
69 {
70 if (!(this.source?.ForAllChildNodes(Callback, State, Order) ?? true))
71 return false;
72 }
73
74 bool b;
75
76 if (!(this.source is null))
77 {
78 b = !Callback(this.source, out ScriptNode NewNode, State);
79 if (!(NewNode is null) && NewNode is SourceDefinition Source2)
80 {
81 this.source = Source2;
82 this.source.SetParent(this);
83 }
84
85 if (b || (Order == SearchMethod.TreeOrder && !this.source.ForAllChildNodes(Callback, State, Order)))
86 return false;
87 }
88
89 if (Order == SearchMethod.BreadthFirst)
90 {
91 if (!(this.source?.ForAllChildNodes(Callback, State, Order) ?? true))
92 return false;
93 }
94
95 return true;
96 }
97
99 public override bool Equals(object obj)
100 {
101 return (obj is DropCollection O &&
102 AreEqual(this.source, O.source) &&
103 base.Equals(obj));
104 }
105
107 public override int GetHashCode()
108 {
109 int Result = base.GetHashCode();
110 Result ^= Result << 5 ^ GetHashCode(this.source);
111 return Result;
112 }
113
114 }
115}
Class managing a script expression.
Definition: Expression.cs:39
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
static bool AreEqual(ScriptNode S1, ScriptNode S2)
Compares if two script nodes are equal.
Definition: ScriptNode.cs:275
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
void SetParent(ScriptNode Parent)
Sets the parent node. Can only be used when expression is being parsed.
Definition: ScriptNode.cs:132
static readonly ObjectValue Null
Null value.
Definition: ObjectValue.cs:86
Executes an DROP INDEX ... ON ... statement against the object database.
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node asynchronously, using the variables provided in the Variables collection.
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
DropCollection(SourceDefinition Source, int Start, int Length, Expression Expression)
Executes an DROP COLLECTION|TABLE ... statement against the object database.
Abstract base class for source definitions
abstract Task< IDataSource > GetSource(Variables Variables)
Gets the actual data source, from its definition.
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
Interface for script nodes with asynchronous evaluation
Interface for data sources that can be used in SQL statements.
Definition: IDataSource.cs:13
Task DropCollection()
Drops the collection from the source.
delegate bool ScriptNodeEventHandler(ScriptNode Node, out ScriptNode NewNode, object State)
Delegate for ScriptNode callback methods.
SearchMethod
Method to traverse the expression structure
Definition: ScriptNode.cs:38