Esempio n. 1
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = string.Empty;
            output.Content.SetHtmlContent(string.Empty);
            var    rc  = context.GetFatherReductionContext();
            string res = null;

            res = (await output.GetChildContentAsync()).GetContent();
            rc.Results.Add(new ReductionResult(TagTokens.Content, 0, new KeyValuePair <string, string>(ZoneName, res)));
        }
Esempio n. 2
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            if (For == null)
            {
                throw new ArgumentNullException(ForAttributeName);
            }
            if (KeyName == null && !FromRow.HasValue)
            {
                throw new ArgumentNullException(KeyAttributeName);
            }
            var rc = context.GetFatherReductionContext();

            if (rc.RowParsingDisabled)
            {
                output.TagName = string.Empty;
                output.Content.SetHtmlContent(string.Empty);
                return;
            }
            var nc = new ReductionContext(TagTokens.Row, 0, rc.Defaults);

            context.SetChildrenReductionContext(nc);
            await output.GetChildContentAsync();

            RowType inherit = null;

            if (FromRow.HasValue)
            {
                var count = 0;
                foreach (var item in rc.Results)
                {
                    if (item.Token == TagTokens.Row)
                    {
                        if (FromRow.Value == count)
                        {
                            inherit = item.Result as RowType;
                            continue;
                        }
                        else
                        {
                            count++;
                        }
                    }
                }
            }
            var collector = new RowCollector(nc, FromRow);
            var res       = collector.Process(this, rc.Defaults);

            if (res != null)
            {
                rc.Results.Add(new ReductionResult(TagTokens.Row, 0, res));
            }
            output.TagName = string.Empty;
            output.Content.SetHtmlContent(string.Empty);
        }
Esempio n. 3
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var rc = context.GetFatherReductionContext();

            output.TagName = string.Empty;
            output.Content.SetHtmlContent(string.Empty);

            //get row definitions
            IList <RowType> rows = string.IsNullOrEmpty(RowsCacheKey) ?
                                   null :
                                   RowType.GetRowsCollection(RowsCacheKey);
            IList <KeyValuePair <string, string> > toolbars = string.IsNullOrEmpty(RowsCacheKey) ?
                                                              null :
                                                              RowType.GetToolbarsCollection(RowsCacheKey);

            if (rows != null || toolbars != null)
            {
                return;
            }
            var currProvider     = ViewContext.TagHelperProvider();
            var defaultTemplates = currProvider.GetDefaultTemplates(TagHlperForDefaults);
            var nc = new ReductionContext(TagTokens.RowContainer, 0, defaultTemplates, rows != null);

            TagContextHelper.OpenRowContainerContext(contextAccessor.HttpContext);
            context.SetChildrenReductionContext(nc);
            await output.GetChildContentAsync();

            var collector = new RowContainerCollector(nc);
            var res       = collector.Process(this, defaultTemplates) as Tuple <IList <RowType>, IList <KeyValuePair <string, string> > >;

            if (rows == null)
            {
                rows = res.Item1;
                if (!string.IsNullOrEmpty(RowsCacheKey))
                {
                    RowType.CacheRowGroup(RowsCacheKey, rows, contextAccessor.HttpContext, true);
                }
            }
            if (toolbars == null)
            {
                toolbars = res.Item2;
                if (!string.IsNullOrEmpty(RowsCacheKey))
                {
                    RowType.CacheToolbarGroup(RowsCacheKey, toolbars, contextAccessor.HttpContext, true);
                }
            }
            TagContextHelper.CloseRowContainerContext(contextAccessor.HttpContext, new Tuple <IList <RowType>, IList <KeyValuePair <string, string> > >(rows, toolbars));
        }
Esempio n. 4
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (DisplayProperty == null)
            {
                new ArgumentNullException("display-property");
            }
            if (string.IsNullOrWhiteSpace(ItemsDisplayProperty))
            {
                new ArgumentNullException("items-display-property");
            }
            if (string.IsNullOrWhiteSpace(ItemsValueProperty))
            {
                new ArgumentNullException("items-value-property");
            }
            var rc = context.GetFatherReductionContext();

            rc.Results.Add(new ReductionResult(TagTokens.ExternalKeyConnection, 0, GetExpernalConnection()));
        }
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            if (string.IsNullOrWhiteSpace(ViewName))
            {
                new ArgumentNullException(ViewNameName);
            }
            var rc = context.GetFatherReductionContext();

            output.TagName = string.Empty;
            (helper as IViewContextAware).Contextualize(ViewContext);
            var vd = new ViewDataDictionary <object>(ViewContext.ViewData);

            vd.Model        = For.Model;
            vd[contextName] = rc;
            vd.Remove(RenderingScope.Field);
            var res = await helper.PartialAsync(ViewName, For.Model, vd);

            output.TagName = string.Empty;
            output.Content.SetHtmlContent(res);
        }
Esempio n. 6
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var rc = context.GetFatherReductionContext();

            if (rc.RowParsingDisabled)
            {
                output.TagName = string.Empty;
                output.Content.SetHtmlContent(string.Empty);
                return;
            }
            var nc = new ReductionContext(TagTokens.Column, 0, rc.Defaults);

            context.SetChildrenReductionContext(nc);
            await output.GetChildContentAsync();

            output.TagName = string.Empty;
            output.Content.SetHtmlContent(string.Empty);
            var collector = new ColumnCollector(nc);

            rc.Results.Add(new ReductionResult(TagTokens.Column, Remove ? -1 : 1, collector.Process(this, rc.Defaults)));
        }
Esempio n. 7
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (Partial == null && ViewComponent == null && !cloned)
            {
                var clone = this.MemberwiseClone() as TemplateTagHelper;
                clone.cloned = true;
                var fun = typeof(TagHelperOutput).GetTypeInfo()
                          .GetField("_getChildContentAsync", BindingFlags.NonPublic | BindingFlags.Instance)
                          .GetValue(output) as Func <bool, HtmlEncoder, Task <TagHelperContent> >;
                var exContext = fun.Target as TagHelperExecutionContext;
                var _startTagHelperWritingScope = typeof(TagHelperExecutionContext)
                                                  .GetField("_startTagHelperWritingScope", BindingFlags.NonPublic | BindingFlags.Instance)
                                                  .GetValue(exContext) as Action <HtmlEncoder>;
                var _endTagHelperWritingScope = typeof(TagHelperExecutionContext)
                                                .GetField("_endTagHelperWritingScope", BindingFlags.NonPublic | BindingFlags.Instance)
                                                .GetValue(exContext) as Func <TagHelperContent>;
                var _executeChildContentAsync = typeof(TagHelperExecutionContext)
                                                .GetField("_executeChildContentAsync", BindingFlags.NonPublic | BindingFlags.Instance)
                                                .GetValue(exContext) as Func <Task>;
                var newExContext = new TagHelperExecutionContext("asp-template", TagMode.StartTagAndEndTag, exContext.Items, context.UniqueId,
                                                                 _executeChildContentAsync,
                                                                 _startTagHelperWritingScope,
                                                                 _endTagHelperWritingScope
                                                                 );
                newExContext.TagHelpers.Add(exContext.TagHelpers[0]);
                newExContext.AddHtmlAttribute(context.AllAttributes["type"]);
                clone.Process(newExContext.Context, newExContext.Output);
                output.SuppressOutput();
                return;
            }
            var rc = context.GetFatherReductionContext();

            output.SuppressOutput();

            if (rc.RowParsingDisabled)
            {
                return;
            }

            if (rc.CurrentToken == TagTokens.Column)
            {
                rc.Results.Add(new ReductionResult(
                                   templateToken(),
                                   0,
                                   Partial != null || ViewComponent != null ?
                                   new Template <Column>(Partial != null ? TagHelpers.TemplateType.Partial : TagHelpers.TemplateType.ViewComponent,
                                                         Partial ?? ViewComponent)
                    :
                                   new Template <Column>(TemplateFunction == null ? TagHelpers.TemplateType.InLine : TagHelpers.TemplateType.Function,
                                                         TemplateFunction != null ? TemplateFunction
                        :
                                                         (x, y, z) =>
                {
                    var t = output.GetChildContentAsync(false);
                    t.Wait();
                    return(new HtmlString(t.Result.GetContent().ToString()));
                },
                                                         ViewContext
                                                         )));
            }
            else
            {
                rc.Results.Add(new ReductionResult(
                                   templateToken(),
                                   0,
                                   Partial != null || ViewComponent != null ?
                                   new Template <RowType>(Partial != null ? TagHelpers.TemplateType.Partial : TagHelpers.TemplateType.ViewComponent,
                                                          Partial ?? ViewComponent)
                    :
                                   new Template <RowType>(TemplateFunction == null ? TagHelpers.TemplateType.InLine : TagHelpers.TemplateType.Function,
                                                          TemplateFunction != null ? TemplateFunction
                        :
                                                          (x, y, z) =>
                {
                    var t = output.GetChildContentAsync(false);
                    t.Wait();
                    return(new HtmlString(t.Result.GetContent().ToString()));
                },
                                                          ViewContext
                                                          )));
            }
        }