Exemplo n.º 1
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            int i;

            if (DepthFirst)
            {
                if (!ForAllChildNodes(Callback, this.arguments, State, DepthFirst))
                {
                    return(false);
                }
            }

            for (i = 0; i < this.nrArguments; i++)
            {
                if (!Callback(ref this.arguments[i], State))
                {
                    return(false);
                }
            }

            if (!DepthFirst)
            {
                if (!ForAllChildNodes(Callback, this.arguments, State, DepthFirst))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            if (DepthFirst)
            {
                if (!this.op.ForAllChildNodes(Callback, State, DepthFirst))
                {
                    return(false);
                }
            }

            if (!Callback(ref this.op, State))
            {
                return(false);
            }

            if (!DepthFirst)
            {
                if (!this.op.ForAllChildNodes(Callback, State, DepthFirst))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            if (DepthFirst)
            {
                if (!(this.argument?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            if (!(this.argument is null) && !Callback(ref this.argument, State))
            {
                return(false);
            }

            if (!DepthFirst)
            {
                if (!(this.argument?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            int i, c = this.elements.Length;

            if (DepthFirst)
            {
                if (!ForAllChildNodes(Callback, this.elements, State, DepthFirst))
                {
                    return(false);
                }
            }

            for (i = 0; i < c; i++)
            {
                if (!(this.elements[i] is null) && !Callback(ref this.elements[i], State))
                {
                    return(false);
                }
            }

            if (!DepthFirst)
            {
                for (i = 0; i < c; i++)
                {
                    if (!ForAllChildNodes(Callback, this.elements, State, DepthFirst))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            LinkedListNode <KeyValuePair <string, ScriptNode> > Loop;

            if (DepthFirst)
            {
                Loop = this.members.First;

                while (!(Loop is null))
                {
                    if (!(Loop.Value.Value?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                    {
                        return(false);
                    }

                    Loop = Loop.Next;
                }
            }

            Loop = this.members.First;

            while (!(Loop is null))
            {
                ScriptNode Node = Loop.Value.Value;
                if (!(Node is null))
                {
                    bool Result = Callback(ref Node, State);
                    if (Loop.Value.Value != Node)
                    {
                        Loop.Value = new KeyValuePair <string, ScriptNode>(Loop.Value.Key, Node);
                    }

                    if (!Result)
                    {
                        return(false);
                    }
                }

                Loop = Loop.Next;
            }

            if (!DepthFirst)
            {
                Loop = this.members.First;

                while (!(Loop is null))
                {
                    if (!(Loop.Value.Value?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                    {
                        return(false);
                    }

                    Loop = Loop.Next;
                }
            }

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            LinkedListNode <ScriptNode> Loop;

            if (DepthFirst)
            {
                Loop = this.statements.First;

                while (!(Loop is null))
                {
                    if (!(Loop.Value?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                    {
                        return(false);
                    }

                    Loop = Loop.Next;
                }
            }

            Loop = this.statements.First;

            while (!(Loop is null))
            {
                ScriptNode Node = Loop.Value;
                if (!(Node is null))
                {
                    bool Result = Callback(ref Node, State);
                    Loop.Value = Node;

                    if (!Result)
                    {
                        return(false);
                    }
                }

                Loop = Loop.Next;
            }

            if (!DepthFirst)
            {
                Loop = this.statements.First;

                while (!(Loop is null))
                {
                    if (!(Loop.Value?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                    {
                        return(false);
                    }

                    Loop = Loop.Next;
                }
            }

            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            if (DepthFirst)
            {
                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.where?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            ScriptNode Node = this.source;

            if (!(Node is null) && !Callback(ref Node, State))
            {
                return(false);
            }

            if (Node != this.source)
            {
                if (Node is SourceDefinition Source2)
                {
                    this.source = Source2;
                }
                else
                {
                    return(false);
                }
            }

            if (!(this.where is null) && !Callback(ref this.where, State))
            {
                return(false);
            }

            if (!DepthFirst)
            {
                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.where?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Calls the <see cref="ScriptNode.ForAllChildNodes(ScriptNodeEventHandler, object, bool)"/> method for all nodes in an array.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="Nodes">Script node array</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        protected static bool ForAllChildNodes(ScriptNodeEventHandler Callback, ScriptNode[] Nodes, object State, bool DepthFirst)
        {
            if (!(Nodes is null))
            {
                int i, c = Nodes.Length;

                for (i = 0; i < c; i++)
                {
                    if (!(Nodes[i]?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            int i;

            if (DepthFirst)
            {
                if (!this.type.ForAllChildNodes(Callback, State, DepthFirst))
                {
                    return(false);
                }

                if (!ForAllChildNodes(Callback, this.parameters, State, DepthFirst))
                {
                    return(false);
                }
            }

            if (!Callback(ref this.type, State))
            {
                return(false);
            }

            for (i = 0; i < this.nrParameters; i++)
            {
                if (!Callback(ref this.parameters[i], State))
                {
                    return(false);
                }
            }

            if (!DepthFirst)
            {
                if (!this.type.ForAllChildNodes(Callback, State, DepthFirst))
                {
                    return(false);
                }

                if (!ForAllChildNodes(Callback, this.parameters, State, DepthFirst))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Calls the callback method for all nodes in an array.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="Nodes">Script node array</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <returns>If the process was completed.</returns>
        protected static bool ForAll(ScriptNodeEventHandler Callback, ScriptNode[] Nodes, object State)
        {
            if (!(Nodes is null))
            {
                int        i, c = Nodes.Length;
                ScriptNode Node;

                for (i = 0; i < c; i++)
                {
                    Node = Nodes[i];
                    if (!(Node is null))
                    {
                        if (!Callback(ref Node, State))
                        {
                            return(false);
                        }

                        Nodes[i] = Node;
                    }
                }
            }

            return(true);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            if (DepthFirst)
            {
                if (!this.source.ForAllChildNodes(Callback, State, DepthFirst))
                {
                    return(false);
                }

                foreach (Assignment SetOperation in this.setOperations)
                {
                    if (!SetOperation.ForAllChildNodes(Callback, State, DepthFirst))
                    {
                        return(false);
                    }
                }

                if (this.where != null)
                {
                    if (!this.where.ForAllChildNodes(Callback, State, DepthFirst))
                    {
                        return(false);
                    }
                }
            }

            if (!Callback(ref this.source, State))
            {
                return(false);
            }

            int i, c = this.setOperations.Length;

            for (i = 0; i < c; i++)
            {
                ScriptNode SetOperation = this.setOperations[i];

                if (!Callback(ref SetOperation, State))
                {
                    return(false);
                }

                if (SetOperation is Assignment Assignment)
                {
                    this.setOperations[i] = Assignment;
                }
                else
                {
                    return(false);
                }
            }

            if (this.where != null)
            {
                if (!Callback(ref this.where, State))
                {
                    return(false);
                }
            }

            if (!DepthFirst)
            {
                if (!this.source.ForAllChildNodes(Callback, State, DepthFirst))
                {
                    return(false);
                }

                foreach (Assignment SetOperation in this.setOperations)
                {
                    if (!SetOperation.ForAllChildNodes(Callback, State, DepthFirst))
                    {
                        return(false);
                    }
                }

                if (this.where != null)
                {
                    if (!this.where.ForAllChildNodes(Callback, State, DepthFirst))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            if (DepthFirst)
            {
                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                foreach (Assignment SetOperation in this.setOperations)
                {
                    if (!(SetOperation?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                    {
                        return(false);
                    }
                }

                if (!(this.where?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            ScriptNode Node = this.source;

            if (!(Node is null) && !Callback(ref Node, State))
            {
                return(false);
            }

            if (Node != this.source)
            {
                if (Node is SourceDefinition Source2)
                {
                    this.source = Source2;
                }
                else
                {
                    return(false);
                }
            }

            int i, c = this.setOperations.Length;

            for (i = 0; i < c; i++)
            {
                ScriptNode SetOperation = this.setOperations[i];

                if (!(SetOperation is null))
                {
                    if (!Callback(ref SetOperation, State))
                    {
                        return(false);
                    }

                    if (SetOperation is Assignment Assignment)
                    {
                        this.setOperations[i] = Assignment;
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            if (!(this.where is null) && !Callback(ref this.where, State))
            {
                return(false);
            }

            if (!DepthFirst)
            {
                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                foreach (Assignment SetOperation in this.setOperations)
                {
                    if (!(SetOperation?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                    {
                        return(false);
                    }
                }

                if (!(this.where?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            if (DepthFirst)
            {
                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.columns?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.values?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            ScriptNode Node = this.source;

            if (!(Node is null) && !Callback(ref Node, State))
            {
                return(false);
            }

            if (Node is SourceDefinition Source2)
            {
                this.source = Source2;
            }
            else
            {
                return(false);
            }

            Node = this.columns;
            if (!(Node is null) && !Callback(ref Node, State))
            {
                return(false);
            }

            if (Node is ElementList List1)
            {
                this.columns = List1;
            }
            else
            {
                return(false);
            }

            Node = this.values;
            if (!(Node is null) && !Callback(ref Node, State))
            {
                return(false);
            }

            if (Node is ElementList List2)
            {
                this.values = List2;
            }
            else
            {
                return(false);
            }

            if (!DepthFirst)
            {
                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.columns?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.values?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            if (DepthFirst)
            {
                if (!(this.name?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!ForAllChildNodes(Callback, this.columns, State, DepthFirst))
                {
                    return(false);
                }
            }

            if (!(this.name is null) && !Callback(ref this.name, State))
            {
                return(false);
            }

            ScriptNode Node = this.source;

            if (!(Node is null) && !Callback(ref Node, State))
            {
                return(false);
            }

            if (Node is SourceDefinition Source2)
            {
                this.source = Source2;
            }
            else
            {
                return(false);
            }

            int i;

            for (i = 0; i < this.nrColumns; i++)
            {
                if (!(this.columns[i] is null) && !Callback(ref this.columns[i], State))
                {
                    return(false);
                }
            }

            if (!DepthFirst)
            {
                if (!(this.name?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!ForAllChildNodes(Callback, this.columns, State, DepthFirst))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Calls the callback method for all child nodes.
 /// </summary>
 /// <param name="Callback">Callback method to call.</param>
 /// <param name="State">State object to pass on to the callback method.</param>
 /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
 /// <returns>If the process was completed.</returns>
 public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
 {
     return(true);
 }
Exemplo n.º 16
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            if (DepthFirst)
            {
                if (!(this.left?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.middle?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.middle2?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.right?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            if (!(this.left is null) && !Callback(ref this.left, State))
            {
                return(false);
            }

            if (!(this.middle is null) && !Callback(ref this.middle, State))
            {
                return(false);
            }

            if (!(this.middle2 is null) && !Callback(ref this.middle2, State))
            {
                return(false);
            }

            if (!(this.right is null) && !Callback(ref this.right, State))
            {
                return(false);
            }

            if (!DepthFirst)
            {
                if (!(this.left?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.middle?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.middle2?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.right?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Calls the callback method for all child nodes.
 /// </summary>
 /// <param name="Callback">Callback method to call.</param>
 /// <param name="State">State object to pass on to the callback method.</param>
 /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
 /// <returns>If the process was completed.</returns>
 public abstract bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst);
Exemplo n.º 18
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            int        i, c = this.processingInstructions.Length;
            ScriptNode Node;

            if (DepthFirst)
            {
                for (i = 0; i < c; i++)
                {
                    if (!this.processingInstructions[i].ForAllChildNodes(Callback, State, DepthFirst))
                    {
                        return(false);
                    }
                }

                if (!this.root.ForAllChildNodes(Callback, State, DepthFirst))
                {
                    return(false);
                }
            }

            for (i = 0; i < c; i++)
            {
                Node = this.processingInstructions[i];

                if (!Callback(ref Node, State))
                {
                    return(false);
                }

                if (Node != this.processingInstructions[i])
                {
                    if (Node is XmlScriptProcessingInstruction PI)
                    {
                        this.processingInstructions[i] = PI;
                    }
                    else
                    {
                        throw new ScriptRuntimeException("Incompatible node change.", this);
                    }
                }
            }

            Node = this.root;

            if (!Callback(ref Node, State))
            {
                return(false);
            }

            if (Node != this.root)
            {
                if (Node is XmlScriptElement Root)
                {
                    this.root = Root;
                }
                else
                {
                    throw new ScriptRuntimeException("Incompatible node change.", this);
                }
            }

            if (!DepthFirst)
            {
                for (i = 0; i < c; i++)
                {
                    if (!this.processingInstructions[i].ForAllChildNodes(Callback, State, DepthFirst))
                    {
                        return(false);
                    }
                }

                if (!this.root.ForAllChildNodes(Callback, State, DepthFirst))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            if (DepthFirst)
            {
                if (!(this.left?.ForAllChildNodes(Callback, State, DepthFirst) ?? true) ||
                    !(this.right?.ForAllChildNodes(Callback, State, DepthFirst) ?? true) ||
                    !(this.conditions?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            ScriptNode Node = this.left;

            if (!(Node is null) && !Callback(ref Node, State))
            {
                return(false);
            }

            if (Node != this.left)
            {
                if (Node is SourceDefinition Left2)
                {
                    this.left = Left2;
                }
                else
                {
                    return(false);
                }
            }

            Node = this.right;
            if (!(Node is null) && !Callback(ref Node, State))
            {
                return(false);
            }

            if (Node != this.right)
            {
                if (Node is SourceDefinition Right2)
                {
                    this.right = Right2;
                }
                else
                {
                    return(false);
                }
            }

            if (!(this.conditions is null) && !Callback(ref this.conditions, State))
            {
                return(false);
            }

            if (!DepthFirst)
            {
                if (!(this.left?.ForAllChildNodes(Callback, State, DepthFirst) ?? true) ||
                    !(this.right?.ForAllChildNodes(Callback, State, DepthFirst) ?? true) ||
                    !(this.conditions?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            int i, c = this.attributes.Length;
            LinkedListNode <XmlScriptNode> Loop;
            ScriptNode Node;

            if (DepthFirst)
            {
                for (i = 0; i < c; i++)
                {
                    if (!this.attributes[i].ForAllChildNodes(Callback, State, DepthFirst))
                    {
                        return(false);
                    }
                }

                Loop = this.children?.First;
                while (!(Loop is null))
                {
                    if (!Loop.Value.ForAllChildNodes(Callback, State, DepthFirst))
                    {
                        return(false);
                    }

                    Loop = Loop.Next;
                }
            }

            for (i = 0; i < c; i++)
            {
                Node = this.attributes[i];

                if (!Callback(ref Node, State))
                {
                    return(false);
                }

                if (Node != this.attributes[i])
                {
                    if (Node is XmlScriptAttribute Attr)
                    {
                        this.attributes[i] = Attr;
                    }
                    else
                    {
                        throw new ScriptRuntimeException("Incompatible node change.", this);
                    }
                }
            }

            Loop = this.children?.First;
            while (!(Loop is null))
            {
                Node = Loop.Value;

                if (!Callback(ref Node, State))
                {
                    return(false);
                }

                if (Node != Loop.Value)
                {
                    if (Node is XmlScriptNode Node2)
                    {
                        Loop.Value = Node2;
                    }
                    else
                    {
                        throw new ScriptRuntimeException("Incompatible node change.", this);
                    }
                }

                Loop = Loop.Next;
            }

            if (!DepthFirst)
            {
                for (i = 0; i < c; i++)
                {
                    if (!this.attributes[i].ForAllChildNodes(Callback, State, DepthFirst))
                    {
                        return(false);
                    }
                }

                Loop = this.children?.First;
                while (!(Loop is null))
                {
                    if (!Loop.Value.ForAllChildNodes(Callback, State, DepthFirst))
                    {
                        return(false);
                    }

                    Loop = Loop.Next;
                }
            }

            return(true);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            int i, c;

            if (DepthFirst)
            {
                if (!ForAllChildNodes(Callback, this.columns, State, DepthFirst) ||
                    !ForAllChildNodes(Callback, this.columnNames, State, DepthFirst) ||
                    !ForAllChildNodes(Callback, this.sources, State, DepthFirst) ||
                    !ForAllChildNodes(Callback, this.sourceNames, State, DepthFirst) ||
                    !ForAllChildNodes(Callback, this.groupBy, State, DepthFirst) ||
                    !ForAllChildNodes(Callback, this.groupByNames, State, DepthFirst) ||
                    !(this.top?.ForAllChildNodes(Callback, State, DepthFirst) ?? true) ||
                    !(this.where?.ForAllChildNodes(Callback, State, DepthFirst) ?? true) ||
                    !(this.having?.ForAllChildNodes(Callback, State, DepthFirst) ?? true) ||
                    !(this.offset?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (this.orderBy != null)
                {
                    c = this.orderBy.Length;
                    for (i = 0; i < c; i++)
                    {
                        if (!this.orderBy[i].Key.ForAllChildNodes(Callback, State, DepthFirst))
                        {
                            return(false);
                        }
                    }
                }
            }

            if (!ForAllChildNodes(Callback, this.columns, State, DepthFirst) ||
                !ForAllChildNodes(Callback, this.columnNames, State, DepthFirst) ||
                !ForAllChildNodes(Callback, this.sources, State, DepthFirst) ||
                !ForAllChildNodes(Callback, this.sourceNames, State, DepthFirst) ||
                !ForAllChildNodes(Callback, this.groupBy, State, DepthFirst) ||
                !ForAllChildNodes(Callback, this.groupByNames, State, DepthFirst))
            {
                return(false);
            }

            if (this.top != null)
            {
                Callback(ref this.top, State);
            }

            if (this.where != null)
            {
                Callback(ref this.where, State);
            }

            if (this.having != null)
            {
                Callback(ref this.having, State);
            }

            if (this.offset != null)
            {
                Callback(ref this.offset, State);
            }

            if (this.orderBy != null)
            {
                c = this.orderBy.Length;
                for (i = 0; i < c; i++)
                {
                    ScriptNode Node  = this.orderBy[i].Key;
                    ScriptNode Node0 = Node;

                    if (!Callback(ref Node, State))
                    {
                        return(false);
                    }

                    if (Node != Node0)
                    {
                        this.orderBy[i] = new KeyValuePair <ScriptNode, bool>(Node, this.orderBy[i].Value);
                    }
                }
            }

            if (!DepthFirst)
            {
                if (!ForAllChildNodes(Callback, this.columns, State, DepthFirst) ||
                    !ForAllChildNodes(Callback, this.columnNames, State, DepthFirst) ||
                    !ForAllChildNodes(Callback, this.sources, State, DepthFirst) ||
                    !ForAllChildNodes(Callback, this.sourceNames, State, DepthFirst) ||
                    !ForAllChildNodes(Callback, this.groupBy, State, DepthFirst) ||
                    !ForAllChildNodes(Callback, this.groupByNames, State, DepthFirst) ||
                    !(this.top?.ForAllChildNodes(Callback, State, DepthFirst) ?? true) ||
                    !(this.where?.ForAllChildNodes(Callback, State, DepthFirst) ?? true) ||
                    !(this.having?.ForAllChildNodes(Callback, State, DepthFirst) ?? true) ||
                    !(this.offset?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (this.orderBy != null)
                {
                    c = this.orderBy.Length;
                    for (i = 0; i < c; i++)
                    {
                        if (!this.orderBy[i].Key.ForAllChildNodes(Callback, State, DepthFirst))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }