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

            foreach (var item in GetChildren())
            {
                item.Root = parent.Root;
            }
        }
예제 #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);
 }
예제 #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;
        }
예제 #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);
                    }
                }
            }
        }
예제 #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);
        }
예제 #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);
                }
            }
        }
예제 #11
0
 public void SetRight(ExpressionTreeBase right)
 {
     Right = right;
 }
예제 #12
0
 public SelectorExpression(SelectorTypes field, ModifierTypes modifier, ExpressionTreeBase left) : this()
 {
     NodeType = field;
     Modifier = modifier;
     SetLeft(left);
 }
예제 #13
0
 public void AddSelect(ExpressionTreeBase sel)
 {
     sel.SetParent(this);
     _selects.Add(sel as DimensionExpression);
 }
예제 #14
0
 public void AddDimension(ExpressionTreeBase dim)
 {
     dim.SetParent(this);
     _dimensions.Add(dim as DimensionExpression);
 }
예제 #15
0
 public void AddChild(ExpressionTreeBase child)
 {
     _children.Add(child);
     child.SetParent(this);
 }
예제 #16
0
 public void AddItem(ExpressionTreeBase lit)
 {
     AddChild(lit);
 }