public OrPredicate Read_OrPredicate(XmlNode nodeRepresentation)
        {
            OrPredicate predicate = new OrPredicate();

            foreach (XmlNode childNode in nodeRepresentation.ChildNodes)
            {
                TextPredicate child = this.ReadTextPredicate(childNode);
                predicate.AddChild(child);
            }
            return(predicate);
        }
        private void OrButton_Clicked(object sender, EventArgs e)
        {
            OrPredicate   or    = new OrPredicate();
            TextPredicate child = this.getPendingChildPredicate();

            if (child != null)
            {
                or.AddChild(child);
                this.openPredicates.Add(or);
            }
            else
            {
                this.addChild(or);
            }
            this.updateLayout();
        }
        // add the given predicate as a child of the leafmost existing predicate
        private void addChild(TextPredicate predicate)
        {
            if (this.openPredicates.Count < 1)
            {
                // no predicates already exist, this one becomes the primary one
                this.openPredicates.Add(predicate);
                return;
            }
            TextPredicate last = this.openPredicates.Last();
            OrPredicate   or   = last as OrPredicate;

            if (or != null)
            {
                // we have a pending 'or'; add it here
                or.AddChild(predicate);
                return;
            }
            AndPredicate and = last as AndPredicate;

            if (and != null)
            {
                // we have a pending 'and'; add it here
                and.AddChild(predicate);
                return;
            }
            NotPredicate not = last as NotPredicate;

            if (not != null)
            {
                // we have a pending 'not'; add it here
                not.Child = predicate;
                return;
            }
            if (last == null)
            {
                // We have an empty spot to add this predicate to
                // This user is expected to attach this to a parent later
                // If the user doesn't attach this to a parent later, we will for them
                this.openPredicates.RemoveAt(this.openPredicates.Count - 1);
                this.openPredicates.Add(predicate);
                return;
            }
            // error; do nothing
        }