Пример #1
0
        public static int?Integer(PlSqlParser.NumericContext context)
        {
            if (context == null)
            {
                return(null);
            }

            var text = context.GetText();
            int value;

            if (!Int32.TryParse(text, out value))
            {
                throw new ParseCanceledException(String.Format("Numeric '{0}' is not an integer.", text));
            }

            return(value);
        }
Пример #2
0
        public static int?PositiveInteger(PlSqlParser.NumericContext context)
        {
            if (context == null)
            {
                return(null);
            }

            var text = context.GetText();

            if (!Int32.TryParse(text, out var value))
            {
                throw new ParseCanceledException($"Numeric '{text}' is not an integer.");
            }
            if (value < 0)
            {
                throw new ParseCanceledException($"Integer '{text}' is not positive.");
            }

            return(value);
        }