コード例 #1
0
        public override Element VisitWhenExpressionExp(WhenExpressionExpContext context)
        {
            var whenExpresion = new WhenExpression(CreateParseInfo(context));

            whenExpresion.Children.Add(Visit(context.b));
            whenExpresion.Children.Add(Visit(context.s));

            return(whenExpresion);
        }
コード例 #2
0
        /// <summary>
        /// Creates a <see cref="CasesColumn"/>
        /// </summary>
        /// <param name="first"></param>
        /// <param name="others"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"> if <paramref name="whenExpressions"/> is <c>null</c></exception>
        public static CasesColumn Cases(WhenExpression first, params WhenExpression[] others)
        {
            if (first == null)
            {
                throw new ArgumentNullException(nameof(first));
            }

            if (others == null)
            {
                throw new ArgumentNullException(nameof(others));
            }

            return(new CasesColumn(new[] { first }.Union(others.Where(x => x != null))));
        }
コード例 #3
0
ファイル: OutputLimitClause.cs プロジェクト: valmac/nesper
        /// <summary>Renders the clause in textual representation. </summary>
        /// <param name="writer">to output to</param>
        public void ToEPL(TextWriter writer)
        {
            if (AfterTimePeriodExpression != null)
            {
                writer.Write("after ");
                AfterTimePeriodExpression.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
                writer.Write(" ");
            }
            else if ((AfterNumberOfEvents != null) && (AfterNumberOfEvents != 0))
            {
                writer.Write("after ");
                writer.Write(Convert.ToString(AfterNumberOfEvents));
                writer.Write(" events ");
            }

            if (Selector != OutputLimitSelector.DEFAULT)
            {
                writer.Write(Selector.GetText());
                writer.Write(" ");
            }
            if (Unit == OutputLimitUnit.WHEN_EXPRESSION)
            {
                writer.Write("when ");
                WhenExpression.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);

                if ((ThenAssignments != null) && (ThenAssignments.Count > 0))
                {
                    WriteThenAssignments(writer, ThenAssignments);
                }
            }
            else if (Unit == OutputLimitUnit.CRONTAB_EXPRESSION)
            {
                writer.Write("at (");
                String delimiter = "";
                for (int i = 0; i < CrontabAtParameters.Length; i++)
                {
                    writer.Write(delimiter);
                    CrontabAtParameters[i].ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
                    delimiter = ", ";
                }
                writer.Write(")");
            }
            else if (Unit == OutputLimitUnit.TIME_PERIOD && TimePeriodExpression != null)
            {
                writer.Write("every ");
                TimePeriodExpression.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
            }
            else if (Unit == OutputLimitUnit.AFTER)
            {
                // no action required
            }
            else if (Unit == OutputLimitUnit.CONTEXT_PARTITION_TERM)
            {
                writer.Write("when terminated");
                OutputAndAfter(writer);
            }
            else
            {
                writer.Write("every ");
                if (FrequencyVariable == null)
                {
                    writer.Write(Convert.ToString(Frequency.AsInt()));
                }
                else
                {
                    writer.Write(FrequencyVariable);
                }
                writer.Write(" events");
            }

            if (IsAndAfterTerminate)
            {
                writer.Write(" and when terminated");
                OutputAndAfter(writer);
            }
        }
コード例 #4
0
 public override string ToString()
 {
     return($"ExprCaseAlter: When->{WhenExpression.ToString()} Then->{ThenExpression.ToString()}");
 }
コード例 #5
0
 public void Visit(WhenExpression statement)
 {
 }