Пример #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);
 }