本文整理汇总了C#中Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext.SetChildrenReductionContext方法的典型用法代码示例。如果您正苦于以下问题:C# TagHelperContext.SetChildrenReductionContext方法的具体用法?C# TagHelperContext.SetChildrenReductionContext怎么用?C# TagHelperContext.SetChildrenReductionContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext
的用法示例。
在下文中一共展示了TagHelperContext.SetChildrenReductionContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessAsync
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
//estabilish context
if (For == null) throw new ArgumentNullException(ForAttributeName);
if (RequiredFunctionalities == null)
{
if(Type == GridType.Immediate)
RequiredFunctionalities = (x) => Functionalities.FullDetail;
else
RequiredFunctionalities = (x) => Functionalities.FullInLine;
}
string fullName = ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(For.Name);
string id = OverrideId ?? TagBuilder.CreateSanitizedId(fullName, IdAttributeDotReplacement);
var currProvider = ViewContext.TagHelperProvider();
var actTagName = TagName + (Type == GridType.Batch ? "-batch" : "-immediate");
var defaultTemplates = currProvider.GetDefaultTemplates(actTagName);
var ctx = new ContextualizedHelpers(ViewContext, html, httpAccessor, component, urlHelperFactory, factory);
//
//get row definitions
IList<RowType> rows = string.IsNullOrEmpty(RowsCacheKey) ?
null :
RowType.GetRowsCollection(RowsCacheKey);
var nc = new ReductionContext(TagTokens.RowContainer, 0,defaultTemplates, rows != null);
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, httpAccessor.HttpContext);
foreach(var row in rows)
{
if(row.ControllerType != null)
{
Action action = () =>
{
ControllerHelpers.DeclareServerRowtype(row.ControllerType, row);
};
CacheViewPartsFilter.AddAction(httpAccessor.HttpContext, action);
}
}
}
var toolbars = res.Item2;
//
//Prepare grid options
var options = new GridOptions(rows, toolbars, Type, id, fullName)
{
CssClass=CssClass,
ErrorMessages=ErrorMessages,
ClientRowSelection=ClientRowSelection,
ServerRowSelection=ServerRowSelection,
LayoutTemplate=defaultTemplates.GetLayoutTemplate(LayoutTemplate),
SubTemplates=defaultTemplates.GetLayoutParts(LayoutParts)
};
//finally process!
await currProvider.GetTagProcessor(actTagName)(context, output, this, options, ctx);
}
示例2: ProcessAsync
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);
}