コード例 #1
0
        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);
        }
コード例 #2
0
        public override void PerformBefore(CaseAlternative node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (!m_inMSAccessSwitch)
            {
                m_sql.Append("WHEN ");
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public void Add(CaseAlternative tail)
        {
            if (tail == null)
            {
                throw new ArgumentNullException("tail");
            }

            if (m_next == null)
            {
                m_next = tail;
            }
            else
            {
                m_next.Add(tail);
            }
        }
コード例 #5
0
        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(", ");
                }
            }
        }
コード例 #6
0
 public virtual void PerformAfter(CaseAlternative node)
 {
 }
コード例 #7
0
 public virtual void PerformOnThen(CaseAlternative node)
 {
 }
コード例 #8
0
 public virtual void PerformBefore(CaseAlternative node)
 {
 }
コード例 #9
0
 public override void PerformAfter(CaseAlternative node)
 {
     PopKnownParent(node);
 }
コード例 #10
0
 public override void PerformBefore(CaseAlternative node)
 {
     PushParent(node);
 }