Пример #1
0
            public override Expression VisitConstantAtom([NotNull] ExpressionParser.ConstantAtomContext context)
            {
                var text = context.GetText();

                if (text.StartsWith("[") && text.EndsWith("]") && string.IsNullOrWhiteSpace(text.Substring(1, text.Length - 2)))
                {
                    return(Expression.ConstantExpression(new JArray()));
                }

                if (text.StartsWith("{") && text.EndsWith("}") && string.IsNullOrWhiteSpace(text.Substring(1, text.Length - 2)))
                {
                    return(Expression.ConstantExpression(new JObject()));
                }

                throw new Exception($"Unrecognized constant: {text}");
            }
            public override Expression VisitConstantAtom([NotNull] ExpressionParser.ConstantAtomContext context)
            {
                var text = context.GetText();

                if (string.IsNullOrWhiteSpace(text.TrimStart('[').TrimEnd(']')))
                {
                    return(Expression.ConstantExpression(new JArray()));
                }

                if (string.IsNullOrWhiteSpace(text.TrimStart('{').TrimEnd('}')))
                {
                    return(Expression.ConstantExpression(new JObject()));
                }

                throw new Exception($"Unrecognized constant: {text}");
            }