Exemple #1
0
        public virtual void Render(TextWriter writer)
        {
            if (!String.IsNullOrEmpty(TemplateContent))
            {
                TemplateLexer lexer = new TemplateLexer(TemplateContent);

                TemplateParser parser = new TemplateParser(lexer.Parse(), this.Context.Analyzer);

                while (parser.MoveNext())
                {
                    parser.Current.Parse(this.Context, writer);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 呈现内容
        /// </summary>
        /// <param name="writer">TextWriter</param>
        public virtual void Render(System.IO.TextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            Tag[] collection;
            //缓存功能,待添加
            if (this._content == null)
            {
                writer.Write(this.TemplateContent);
                return;
            }

            if (!String.IsNullOrEmpty(this._content))
            {
                TemplateLexer lexer = new TemplateLexer(this._content);
                TemplateParser parser = new TemplateParser(lexer.Parse());
                collection = parser.ToArray();
            }
            else
            {
                collection = new Tag[0];
            }

            if (collection.Length > 0)
            {
                for (Int32 i = 0; i < collection.Length; i++)
                {
                    try
                    {
                        collection[i].Parse(this._context, writer);
                    }
                    catch (Exception.TemplateException e)
                    {
                        ThrowException(e, collection[i],writer);
                    }
                    catch (System.Exception e)
                    {
                        System.Exception baseException = e.GetBaseException();
                        Exception.ParseException ex = new Exception.ParseException(baseException.Message, baseException);
                        ThrowException(ex, collection[i], writer);
                    }
                }
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 private Tag[] ParseTag()
 {
     TemplateLexer lexer = new TemplateLexer(this._content);
     TemplateParser parser = new TemplateParser(lexer.Parse());
     return parser.ToArray();
 }