public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { //estabilish context if (For == null) { throw new ArgumentNullException(ForAttributeName); } if (Mode != null && Mode.Metadata.UnderlyingOrModelType != typeof(bool)) { throw new ArgumentException(ModeName, string.Format(Resources.MustBeBool, ModeName)); } if (ModelNullRow != null && Mode.Metadata.UnderlyingOrModelType != typeof(int)) { throw new ArgumentException(ModelNullRowName, string.Format(Resources.MustBeInt, ModelNullRowName)); } var basePrefix = For.Name; if (basePrefix == "Model") { basePrefix = string.Empty; } ; string fullName = ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(basePrefix); string id = OverrideId ?? TagBuilder.CreateSanitizedId(fullName, IdAttributeDotReplacement); var currProvider = ViewContext.TagHelperProvider(); var defaultTemplates = currProvider.GetDefaultTemplates(TagName); var ctx = new Core.Templates.ContextualizedHelpers(ViewContext, html, httpAccessor, component, urlHelperFactory, factory); // //get row definitions IList <RowType> rows = string.IsNullOrEmpty(RowsCacheKey) ? null : RowType.GetRowsCollection(RowsCacheKey); var nc = new Core.OptionsParsing.ReductionContext(Core.OptionsParsing.TagTokens.RowContainer, 0, defaultTemplates, rows != null); context.SetChildrenReductionContext(nc); TagContextHelper.OpenRowContainerContext(httpAccessor.HttpContext); await output.GetChildContentAsync(); var collector = new Core.OptionsParsing.RowContainerCollector(nc); var res = collector.Process(this, defaultTemplates) as Tuple <IList <Core.Templates.RowType>, IList <KeyValuePair <string, string> > >; if (rows == null) { rows = res.Item1; if (!string.IsNullOrEmpty(RowsCacheKey)) { RowType.CacheRowGroup(RowsCacheKey, rows, httpAccessor.HttpContext); } } var toolbars = res.Item2; TagContextHelper.CloseRowContainerContext(httpAccessor.HttpContext, new Tuple <IList <RowType>, IList <KeyValuePair <string, string> > >(rows, toolbars)); //Prepare detail options var options = new Core.TagHelpers.Internals.GridOptions(rows, toolbars, GridType.Batch, id, fullName) { CssClass = CssClass, ErrorMessages = null, ClientRowSelection = ClientRowSelection, ServerRowSelection = ServerRowSelection, LayoutTemplate = defaultTemplates.GetLayoutTemplate(LayoutTemplate), SubTemplates = null }; //finally process! await currProvider.GetTagProcessor(TagName)(context, output, this, options, ctx); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { //estabilish context if (For == null) throw new ArgumentNullException(ForAttributeName); if (Mode != null && Mode.Metadata.UnderlyingOrModelType != typeof(bool)) throw new ArgumentException(ModeName, string.Format(Resources.MustBeBool, ModeName)); if (ModelNullRow != null && Mode.Metadata.UnderlyingOrModelType != typeof(int)) throw new ArgumentException(ModelNullRowName, string.Format(Resources.MustBeInt, ModelNullRowName)); string fullName = ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(For.Name); string id = OverrideId ?? TagBuilder.CreateSanitizedId(fullName, IdAttributeDotReplacement); var currProvider = ViewContext.TagHelperProvider(); var defaultTemplates = currProvider.GetDefaultTemplates(TagName); var ctx = new Core.Templates.ContextualizedHelpers(ViewContext, html, httpAccessor, component, urlHelperFactory, factory); // //get row definitions IList<RowType> rows = string.IsNullOrEmpty(RowsCacheKey) ? null : RowType.GetRowsCollection(RowsCacheKey); var nc = new Core.OptionsParsing.ReductionContext(Core.OptionsParsing.TagTokens.RowContainer, 0, defaultTemplates, rows != null); context.SetChildrenReductionContext(nc); await output.GetChildContentAsync(); var collector = new Core.OptionsParsing.RowContainerCollector(nc); var res = collector.Process(this, defaultTemplates) as Tuple<IList<Core.Templates.RowType>, IList<KeyValuePair<string, string>>>; if (rows == null) { rows = res.Item1; if (!string.IsNullOrEmpty(RowsCacheKey)) RowType.CacheRowGroup(RowsCacheKey, rows, httpAccessor.HttpContext); } var toolbars = res.Item2; //Prepare detail options var options = new Core.TagHelpers.Internals.GridOptions(rows, toolbars, GridType.Batch, id, fullName) { CssClass = CssClass, ErrorMessages = null, ClientRowSelection = ClientRowSelection, ServerRowSelection = ServerRowSelection, LayoutTemplate = defaultTemplates.GetLayoutTemplate(LayoutTemplate), SubTemplates = null }; //finally process! await currProvider.GetTagProcessor(TagName)(context, output, this, options, ctx); }