Exemple #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();
            }

            BindingEndRenderTask bindingEndRenderTask = null;

            if (options.RequireBindingInfo)
            {
                var bindingRenderTask = new BindingRenderTask(new RepeatItemTrace(Alias));
                bindingEndRenderTask = bindingRenderTask.BindingEndRenderTask;
                this.SubTasks.Add(bindingRenderTask);
            }

            if (repeatself)
            {
                string NewHtml = Service.DomService.ReSerializeElement(element, element.InnerHtml);
                this.SubTasks.AddRange(RenderEvaluator.Evaluate(NewHtml, options));
            }
            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)));
                }
                this.SubTasks.AddRange(RenderEvaluator.Evaluate(element.InnerHtml, options));
            }

            if (options.RequireBindingInfo)
            {
                this.SubTasks.Add(bindingEndRenderTask);
            }
        }
Exemple #2
0
        public ForRenderTask(string DataKey, string lowbound, string highbound, bool RepeatSelf, Element element, EvaluatorOption options)
        {
            this.datakey = DataKey;

            long low;

            if (long.TryParse(lowbound, out low))
            {
                this.LowBound = low;
            }
            else
            {
                this.LowBoundKey = lowbound;
            }

            long high;

            if (long.TryParse(highbound, out high))
            {
                this.HighBound = high;
            }
            else
            {
                this.HighBoundKey = highbound;
            }

            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));
                }
            }
        }