public void SetLeft(ExpressionTreeBase left) { if (left != null) { left.SetParent(this); } Left = left; }
public void AddArgument(ExpressionTreeBase dim) { if (dim != null) { dim.SetParent(this); } Dimensions.Add(dim); }
public void SetChild(ExpressionTreeBase child) { Child = child; if (Child != null) { Child.SetParent(this); } }
public void SetMiddle(ExpressionTreeBase child) { Middle = child; if (Middle != null) { Child.SetParent(this); } }
public void SetParent(ExpressionTreeBase parent) { Parent = parent; Root = parent.Root; foreach (var item in GetChildren()) { item.Root = parent.Root; } }
private static JoiningType?GetJoiningType(ExpressionTreeBase item) { if (item is AndCondition) { return(JoiningType.And); } else if (item is OrCondition) { return(JoiningType.Or); } return(null); }
public void SetChildren(ExpressionTreeBase left, ExpressionTreeBase right) { if (left != null) { Left.SetParent(this); } Left = left; if (right != null) { right.SetParent(this); } Right = right; }
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); } } } }
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); }
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); } } }
public void SetRight(ExpressionTreeBase right) { Right = right; }
public SelectorExpression(SelectorTypes field, ModifierTypes modifier, ExpressionTreeBase left) : this() { NodeType = field; Modifier = modifier; SetLeft(left); }
public void AddSelect(ExpressionTreeBase sel) { sel.SetParent(this); _selects.Add(sel as DimensionExpression); }
public void AddDimension(ExpressionTreeBase dim) { dim.SetParent(this); _dimensions.Add(dim as DimensionExpression); }
public void AddChild(ExpressionTreeBase child) { _children.Add(child); child.SetParent(this); }
public void AddItem(ExpressionTreeBase lit) { AddChild(lit); }