Exemple #1
0
 public void SetLeft(ExpressionTreeBase left)
 {
     if (left != null)
     {
         left.SetParent(this);
     }
     Left = left;
 }
Exemple #2
0
 public void AddArgument(ExpressionTreeBase dim)
 {
     if (dim != null)
     {
         dim.SetParent(this);
     }
     Dimensions.Add(dim);
 }
Exemple #3
0
 public void SetChild(ExpressionTreeBase child)
 {
     Child = child;
     if (Child != null)
     {
         Child.SetParent(this);
     }
 }
Exemple #4
0
 public void SetMiddle(ExpressionTreeBase child)
 {
     Middle = child;
     if (Middle != null)
     {
         Child.SetParent(this);
     }
 }
Exemple #5
0
        public void SetParent(ExpressionTreeBase parent)
        {
            Parent = parent;
            Root   = parent.Root;

            foreach (var item in GetChildren())
            {
                item.Root = parent.Root;
            }
        }
Exemple #6
0
 private static JoiningType?GetJoiningType(ExpressionTreeBase item)
 {
     if (item is AndCondition)
     {
         return(JoiningType.And);
     }
     else if (item is OrCondition)
     {
         return(JoiningType.Or);
     }
     return(null);
 }
Exemple #7
0
        public void SetChildren(ExpressionTreeBase left, ExpressionTreeBase right)
        {
            if (left != null)
            {
                Left.SetParent(this);
            }
            Left = left;

            if (right != null)
            {
                right.SetParent(this);
            }
            Right = right;
        }
Exemple #8
0
        public static void PrintTree(ExpressionTreeBase treeItem, int indent)
        {
            string add = "";

            for (int i = 0; i < indent; i++)
            {
                add += "  ";
            }
            Console.Out.WriteLine(add + treeItem);
            indent++;
            if (treeItem is GetExpression)
            {
                //Console.Out.WriteLine(add + "Types: ");
                //foreach (GetTypes current in ((GetExpression)treeItem).Types)
                //{
                //Console.Out.WriteLine(add + current);
                //}
                Console.Out.WriteLine(add + "Conditions: ");
            }
            if (treeItem is MultiNodeTree)
            {
                foreach (ExpressionTreeBase current in ((MultiNodeTree)treeItem).Children)
                {
                    PrintTree(current, indent);
                }
            }
            else if (treeItem is SingleNodeTree)
            {
                PrintTree(((SingleNodeTree)treeItem).Child, indent);
            }
            if (treeItem is ConditionalExpression)
            {
                if (((ConditionalExpression)treeItem).AdditionalConditions.Count > 0)
                {
                    //Console.Out.WriteLine(add + "Additional Conditions:");
                    foreach (ConditionalExpression current in ((ConditionalExpression)treeItem).AdditionalConditions)
                    {
                        PrintTree(current, indent);
                    }
                }
            }
        }
Exemple #9
0
        private static ExpressionTreeBase ExtractItem(ExpressionTreeBase item, out JoiningType?type, out bool negate, out ConditionalExpression lastParent)
        {
            lastParent = null;
            type       = GetJoiningType(item);

            if (item is ConditionalExpression && !(item is NotCondition))
            {
                lastParent = (ConditionalExpression)item;
                item       = ((ConditionalExpression)item).Child;
            }

            if (item is NotCondition)
            {
                negate = true;
                item   = ((NotCondition)item).Child;
            }
            else
            {
                negate = false;
            }

            return(item);
        }
Exemple #10
0
        internal static IEnumerable <LogicalItem> Convert(ExpressionTreeBase item)
        {
            JoiningType?          type;
            bool                  negate;
            ConditionalExpression lastParent;

            ExpressionTreeBase actualItem = ExtractItem(item, out type, out negate, out lastParent);

            LogicalItem result;

            if (actualItem is SelectorExpression)
            {
                result = new LogicalSelector((SelectorExpression)actualItem);
            }
            else if (actualItem is ConditionGroup)
            {
                result = new LogicalGroup((ConditionGroup)actualItem);
            }
            else
            {
                throw new Exception();
            }

            result.Negated     = negate;
            result.JoiningType = type ?? JoiningType.And;

            yield return(result);

            if (lastParent != null)
            {
                foreach (LogicalItem current in lastParent.AdditionalConditions.SelectMany(x => Convert(x)))
                {
                    yield return(current);
                }
            }
        }
Exemple #11
0
 public void SetRight(ExpressionTreeBase right)
 {
     Right = right;
 }
Exemple #12
0
 public SelectorExpression(SelectorTypes field, ModifierTypes modifier, ExpressionTreeBase left) : this()
 {
     NodeType = field;
     Modifier = modifier;
     SetLeft(left);
 }
Exemple #13
0
 public void AddSelect(ExpressionTreeBase sel)
 {
     sel.SetParent(this);
     _selects.Add(sel as DimensionExpression);
 }
Exemple #14
0
 public void AddDimension(ExpressionTreeBase dim)
 {
     dim.SetParent(this);
     _dimensions.Add(dim as DimensionExpression);
 }
Exemple #15
0
 public void AddChild(ExpressionTreeBase child)
 {
     _children.Add(child);
     child.SetParent(this);
 }
Exemple #16
0
 public void AddItem(ExpressionTreeBase lit)
 {
     AddChild(lit);
 }