Exemple #1
0
        public string RenderTemplate(Selector subject, HtmlRenderContext context)
        {
            var select = (Select)subject.Context.GetUntypedValue(context.Region.Semantics);

            var data = new SelectorRenderData
                           {
                               Selector = subject,
                               RenderContext = context,
                               Comparison = context.Serializer.RenderInstance(subject.ComparisonExpression),
                               Symbol = (subject.Symbol == null) ? null : context.Serializer.RenderInstance(subject.Symbol),
                               Tip = (subject.Tip == null) ? null : context.Serializer.RenderInstance(subject.Tip),
                               From = context.Serializer.RenderInstance(subject.AllItems),
                               Current = context.Serializer.RenderInstance(subject.SelectedItems),
                               AvailableTemplateScript = (subject.AvailableTemplate == null) ? null : context.RenderTemplate(subject.AvailableTemplate.Tree),
                               SelectedTemplateScript = (subject.SelectedTemplate == null) ? null : context.RenderTemplate(subject.SelectedTemplate.Tree),
                               CaptureId = select.CaptureId,
                               CaptureKeyScript = (select.CaptureKey == null) ? null : context.Serializer.RenderInstance(select.CaptureKey)
                           };

            var cf = subject.Filter as CategoryFilter;
            if (cf != null)
            {
                data.CategoryFilter = true;
                data.Categories = context.Serializer.RenderInstance(cf.Categories);
                data.Category = context.Serializer.RenderInstance(cf.Category);
                data.CompareCategories = context.Serializer.RenderInstance(cf.CompareCategories);
                data.GetCategoryKey = context.Serializer.RenderInstance(cf.GetCategoryKey);
                data.GetItemCategories = context.Serializer.RenderInstance(cf.GetItemCategories);
            }

            var tt = new SelectorTemplate { Session = new Dictionary<string, object> {{ "Data", data }} };
            tt.Initialize();
            return tt.TransformText();
        }
Exemple #2
0
        public string Render(AppRegion region)
        {
            var rctx = new HtmlRenderContext(region);

            var data = new HtmlRenderData
                            {
                                RenderContext = rctx,
                                SemanticsScript = new SemanticsRenderer().Render(rctx),
                                TemplateScript = rctx.RenderTemplate(rctx.Region.Template.Tree)
                            };

            var tt = new RenderRegionTemplate { Session = new Dictionary<string, object> {{"Data", data }} };
            tt.Initialize();
            return tt.TransformText();
        }