Esempio n. 1
0
        public TagMarkupBase ParseTag(string markup, int lineNumber, int charPos)
        {
            ForEachTagMarkup tagMarkup        = null;
            ExpressionMarkup expressionMarkup = null;

            Match m = ForEachTagParserRegex.Match(markup);

            if (m.Success)
            {
                string tag = m.Groups["Tag"].Success ? m.Groups["Tag"].Value.Trim(): null;
                if (string.IsNullOrEmpty(tag))
                {
                    throw new ImpressionParseException("Unsupported Tag Found", markup, lineNumber, charPos);
                }

                string expression = m.Groups["Expression"].Success ? m.Groups["Expression"].Value.Trim() : null;
                if (!string.IsNullOrEmpty(expression))
                {
                    expressionMarkup = new ExpressionMarkup(reflector, filterRunner, expression, lineNumber, charPos);
                }

                switch (tag.ToLower())
                {
                case "foreach":
                    if (expressionMarkup == null)
                    {
                        throw new ImpressionParseException("FOREACH Tag detected without expression", markup, lineNumber, charPos);
                    }

                    tagMarkup = new ForEachTagMarkup(
                        ForEachTagType.ForEach,
                        expressionMarkup,
                        markup,
                        lineNumber,
                        charPos
                        );

                    break;

                case "next":
                    tagMarkup = new ForEachTagMarkup(
                        ForEachTagType.Next,
                        null,
                        markup,
                        lineNumber,
                        charPos
                        );
                    break;
                }
            }

            if (tagMarkup == null)
            {
                throw new ImpressionParseException("Unsupported Tag Found", markup, lineNumber, charPos);
            }

            return(tagMarkup);
        }
Esempio n. 2
0
        public TagMarkupBase ParseTag(string markup, int lineNumber, int charPos)
        {
            ForEachTagMarkup tagMarkup = null;
            ExpressionMarkup expressionMarkup = null;

            Match m = ForEachTagParserRegex.Match(markup);
            if (m.Success) {

                string tag = m.Groups["Tag"].Success ? m.Groups["Tag"].Value.Trim(): null;
                if (string.IsNullOrEmpty(tag))
                    throw new ImpressionParseException("Unsupported Tag Found", markup, lineNumber, charPos);

                string expression = m.Groups["Expression"].Success ? m.Groups["Expression"].Value.Trim() : null;
                if (!string.IsNullOrEmpty(expression))
                {
                    expressionMarkup = new ExpressionMarkup(reflector, filterRunner, expression, lineNumber, charPos);
                }

                switch(tag.ToLower())
                {
                    case "foreach":
                        if (expressionMarkup == null)
                            throw new ImpressionParseException("FOREACH Tag detected without expression", markup, lineNumber, charPos);

                        tagMarkup = new ForEachTagMarkup(
                            ForEachTagType.ForEach,
                            expressionMarkup,
                            markup,
                            lineNumber,
                            charPos
                        );

                        break;

                    case "next":
                        tagMarkup = new ForEachTagMarkup(
                            ForEachTagType.Next,
                            null,
                            markup,
                            lineNumber,
                            charPos
                        );
                        break;

                }
            }

            if (tagMarkup == null)
                throw new ImpressionParseException("Unsupported Tag Found", markup, lineNumber, charPos);

            return tagMarkup;
        }