Ejemplo n.º 1
0
        public RepeatRenderTask(string DataKey, string Alias, bool RepeatSelf, Element element, EvaluatorOption options)
        {
            this.datakey    = DataKey;
            this.alias      = Alias;
            this.repeatself = RepeatSelf;
            string boundary = null;

            if (options.RequireBindingInfo)
            {
                boundary = Kooboo.Lib.Helper.StringHelper.GetUniqueBoundary();
            }

            if (repeatself)
            {
                string NewHtml = Service.DomService.ReSerializeElement(element, element.InnerHtml);

                if (options.RequireBindingInfo)
                {
                    this.SubTasks.Add(new BindingTextContentItemRenderTask(this.alias, boundary, false));
                }
                this.SubTasks.AddRange(RenderEvaluator.Evaluate(NewHtml, options));

                if (options.RequireBindingInfo)
                {
                    this.SubTasks.Add(new BindingTextContentItemRenderTask(this.alias, boundary, true));
                }
            }
            else
            {
                string opentag = string.Empty;

                this.ContainerEndTag = "</" + element.tagName + ">";

                var attributeEvaluator = new AttributeEvaluator();
                var response           = attributeEvaluator.Evaluate(element, options);
                if (response != null && response.AttributeTask != null && response.AttributeTask.Count() > 0)
                {
                    opentag = RenderHelper.GetHalfOpenTag(element);
                    this.ContainerTask.Add(new ContentRenderTask(opentag));
                    this.ContainerTask.AddRange(response.AttributeTask);
                    this.ContainerTask.Add(new ContentRenderTask(">"));
                }
                else
                {
                    this.ContainerTask.Add(new ContentRenderTask(Service.DomService.ReSerializeOpenTag(element)));
                }


                if (options.RequireBindingInfo)
                {
                    this.SubTasks.Add(new BindingTextContentItemRenderTask(this.alias, boundary, false));
                }

                this.SubTasks.AddRange(RenderEvaluator.Evaluate(element.InnerHtml, options));

                if (options.RequireBindingInfo)
                {
                    this.SubTasks.Add(new BindingTextContentItemRenderTask(this.alias, boundary, true));
                }
            }
        }