예제 #1
0
        /// <summary>
        /// 克隆当前元素到新的宿主模板
        /// </summary>
        /// <param name="ownerTemplate"></param>
        /// <returns></returns>
        public override Element Clone(Template ownerTemplate)
        {
            ForEachTag tag = new ForEachTag(ownerTemplate);

            this.CopyTo(tag);
            tag.Else  = this.Else == null ? null : (ForEachElseTag)(this.Else.Clone(ownerTemplate));
            tag.From  = this.From == null ? null : (VariableExpression)this.From.Clone(ownerTemplate);
            tag.Index = this.Index == null ? null : this.Index.Clone(ownerTemplate);
            tag.Item  = this.Item == null ? null : this.Item.Clone(ownerTemplate);

            return(tag);
        }
예제 #2
0
        /// <summary>
        /// 开始解析标签数据
        /// </summary>
        /// <param name="ownerTemplate">宿主模板</param>
        /// <param name="container">标签的容器</param>
        /// <param name="tagStack">标签堆栈</param>
        /// <param name="text"></param>
        /// <param name="match"></param>
        /// <param name="isClosedTag">是否闭合标签</param>
        /// <returns>如果需要继续处理EndTag则返回true.否则请返回false</returns>
        public override bool ProcessBeginTag(Template ownerTemplate, Tag container, Stack <Tag> tagStack, string text, ref Match match, bool isClosedTag)
        {
            //判断标签的容器是否为ForEach标签
            if (!(container is ForEachTag))
            {
                throw new ParserException(string.Format("未找到和{0}标签对应的{1}标签", this.TagName, this.EndTagName));
            }

            ForEachTag foreachTag = (ForEachTag)container;

            if (foreachTag.Else != null)
            {
                throw new ParserException(string.Format("{0}标签不能定义多个{1}标签", this.EndTagName, this.TagName));
            }

            foreachTag.Else = this;

            return(true);
        }
예제 #3
0
        /// <summary>
        /// 克隆当前元素到新的宿主模板
        /// </summary>
        /// <param name="ownerTemplate"></param>
        /// <returns></returns>
        internal override Element Clone(Template ownerTemplate)
        {
            ForEachTag tag = new ForEachTag(ownerTemplate);
            this.CopyTo(tag);
            tag.Else = this.Else == null ? null : (ForEachElseTag)(this.Else.Clone(ownerTemplate));
            tag.From = this.From == null ? null : (VariableExpression)this.From.Clone(ownerTemplate);
            tag.Index = this.Index == null ? null : this.Index.Clone(ownerTemplate);
            tag.Item = this.Item == null ? null : this.Item.Clone(ownerTemplate);

            return tag;
        }