SwitchFunction MakeSwitch(CaseExpression caseExpr) { if (caseExpr == null) { throw new ArgumentNullException("caseExpr"); } IExpression left = caseExpr.Case; SwitchFunction switchFunc = new SwitchFunction(); CaseAlternative alt = caseExpr.Alternatives; if (alt == null) { throw new InvalidOperationException("CASE has no alternatives."); } // branch expressions will be tailored through caseExpr.Alternatives if (left != null) { while (alt != null) { alt.When = new Expression(left.Clone(), ExpressionOperator.Equal, alt.When); CaseAlternative next = alt.Next; alt.Next = null; switchFunc.Add(alt); alt = next; } } else { switchFunc.Alternatives = alt; } IExpression elseExpr = caseExpr.Else; if (elseExpr != null) { // elseExpr will be tailored through caseExpr.Else CaseAlternative last = new CaseAlternative( new Expression( new IntegerValue(1), ExpressionOperator.Equal, new IntegerValue(1)), elseExpr); switchFunc.Add(last); } return(switchFunc); }
public override void PerformBefore(CaseAlternative node) { if (node == null) { throw new ArgumentNullException("node"); } if (!m_inMSAccessSwitch) { m_sql.Append("WHEN "); } }
public INode Clone() { CaseAlternative caseAlternative = new CaseAlternative( (IExpression)(m_when.Clone()), (IExpression)(m_then.Clone())); if (m_next != null) { caseAlternative.Add((CaseAlternative)(m_next.Clone())); } return(caseAlternative); }
public void Add(CaseAlternative tail) { if (tail == null) { throw new ArgumentNullException("tail"); } if (m_next == null) { m_next = tail; } else { m_next.Add(tail); } }
public override void PerformAfter(CaseAlternative node) { if (node == null) { throw new ArgumentNullException("node"); } if (!m_inMSAccessSwitch) { m_sql.Append(NewLine); } else { if (node.HasNext) { m_sql.Append(", "); } } }
public virtual void PerformAfter(CaseAlternative node) { }
public virtual void PerformOnThen(CaseAlternative node) { }
public virtual void PerformBefore(CaseAlternative node) { }
public override void PerformAfter(CaseAlternative node) { PopKnownParent(node); }
public override void PerformBefore(CaseAlternative node) { PushParent(node); }