本文整理汇总了C#中Microsoft.AspNet.Razor.TagHelpers.TagHelperOutput.GetChildContentAsync方法的典型用法代码示例。如果您正苦于以下问题:C# TagHelperOutput.GetChildContentAsync方法的具体用法?C# TagHelperOutput.GetChildContentAsync怎么用?C# TagHelperOutput.GetChildContentAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.AspNet.Razor.TagHelpers.TagHelperOutput
的用法示例。
在下文中一共展示了TagHelperOutput.GetChildContentAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BootstrapProcessAsync
protected override async Task BootstrapProcessAsync(TagHelperContext context, TagHelperOutput output) {
ChildDetectionMode = true;
await output.GetChildContentAsync();
ChildDetectionMode = false;
output.TagName = RenderAsDiv ? "div" : "ul";
output.AddCssClass("list-group");
await output.GetChildContentAsync(false);
}
示例2: Process
public override async void Process(TagHelperContext context, TagHelperOutput output)
{
var originalContent = await output.GetChildContentAsync();
output.AppendClass("form-group");
TagBuilder labelBuilder = null;
if (!originalContent.GetContent().Contains("<label"))
{
labelBuilder = FormGroupLabel.Get(Horizontal, LabelText);
}
var contentDiv = new TagBuilder("div");
if (Horizontal)
{
contentDiv.AddCssClass("col-sm-8");
}
contentDiv.InnerHtml.AppendHtml(originalContent.GetContent());
output.TagName = "div";
output.Content.Clear();
if (labelBuilder != null)
{
output.Content.Append(labelBuilder);
}
output.Content.Append(contentDiv);
base.Process(context, output);
}
示例3: ProcessAsync
/// <inheritdoc />
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (output == null)
{
throw new ArgumentNullException(nameof(output));
}
await output.GetChildContentAsync();
var formContext = ViewContext.FormContext;
if (formContext.HasEndOfFormContent)
{
foreach (var content in formContext.EndOfFormContent)
{
output.PostContent.Append(content);
}
}
// Reset the FormContext
ViewContext.FormContext = null;
}
示例4: GetContent
private async Task<string> GetContent(TagHelperOutput output)
{
if (Content == null)
return (await output.GetChildContentAsync()).GetContent();
return Content.Model?.ToString();
}
示例5: Process
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "div";
if (output.Attributes["class"].IsNull())
{
output.Attributes["class"] = "item";
}
else
{
output.Attributes["class"].Value += " item";
}
/*
<div class="item">
<i class="marker icon"></i>
<div class="content">@Html.DisplayFor(x => item.FullAddress)</div>
</div>
*/
var html = new StringBuilder();
html.Append($"<i class='{Icon} icon'></i>");
html.Append($"<div class='content'>{Content}</div>");
var childContent = output.GetChildContentAsync();
output.Content.SetHtmlContent(html.ToString());
}
示例6: Process
public override async void Process(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "div";
output.AppendClass("widget-box");
output.AppendClass(Class);
var originalContent = await output.GetChildContentAsync();
var innerHtml = originalContent.GetContent();
output.Content.Clear();
if (!innerHtml.Contains(WidgetBoxHeaderHelper.HeaderCss))
{
// user is taking easy/lazy way of declaring the widget box
output.Content.Append(WidgetBoxHeaderHelper.GetFullHeader(Title, IsCollapsible));
var widgetBodyDiv = WidgetBoxBodyHelper.GetFullBodyInternals(Padding, innerHtml);
output.Content.Append(widgetBodyDiv);
}
else
{
// user is doing the hardwork themselves
output.Content.AppendHtml(innerHtml);
}
base.Process(context, output);
}
示例7: ProcessAsync
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var childContent = await output.GetChildContentAsync();
var modalContext = (ModalContext)context.Items[typeof(ModalTagHelper)];
modalContext.Body = childContent;
output.SuppressOutput();
}
示例8: ProcessAsync
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
(HtmlHelper as ICanHasViewContext)?.Contextualize(ViewContext);
var content = await output.GetChildContentAsync();
output.Content.SetContent(HtmlHelper.Hidden(Name, content.GetContent(HtmlEncoder)));
}
示例9: ProcessAsync
/// <inheritdoc />
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (output == null)
{
throw new ArgumentNullException(nameof(output));
}
await output.GetChildContentAsync();
var formContext = ViewContext.FormContext;
if (formContext.HasEndOfFormContent)
{
// Perf: Avoid allocating enumerator
for (var i = 0; i < formContext.EndOfFormContent.Count; i++)
{
output.PostContent.AppendHtml(formContext.EndOfFormContent[i]);
}
}
// Reset the FormContext
ViewContext.FormContext = null;
}
示例10: ProcessAsync
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var bytes = await _redisCache.GetAsync(context.UniqueId);
string content;
if (bytes == null)
{
var childContent = await output.GetChildContentAsync();
content = childContent.GetContent();
bytes = Encoding.UTF8.GetBytes(content);
await _redisCache.SetAsync(context.UniqueId, bytes, new DistributedCacheEntryOptions
{
AbsoluteExpiration = AbsoluteExpiration,
AbsoluteExpirationRelativeToNow = RelativeAbsoluteExpiration,
SlidingExpiration = SlidingExpiration
});
}
else
{
content = Encoding.UTF8.GetString(bytes);
}
output.SuppressOutput();
// Unsupress by setting the content again.
output.Content.SetHtmlContent(content);
}
示例11: ProcessAsync
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var localizer = Localizer ?? GetViewLocalizer();
var aspLocAttr = output.Attributes["asp-loc"];
if (aspLocAttr != null)
{
var resourceKey = aspLocAttr.Minimized
? (await output.GetChildContentAsync()).GetContent()
: aspLocAttr.Value.ToString();
output.Content.SetContent(localizer.GetHtml(resourceKey));
output.Attributes.Remove(aspLocAttr);
}
var localizeAttributes = output.Attributes.Where(attr => attr.Name.StartsWith("asp-loc-", StringComparison.OrdinalIgnoreCase)).ToList();
foreach (var attribute in localizeAttributes)
{
var attributeToLocalize = output.Attributes[attribute.Name.Substring("asp-loc-".Length)];
if (attributeToLocalize != null)
{
var resourceKey = attribute.Minimized
? attributeToLocalize.Value.ToString()
: attribute.Value.ToString();
attributeToLocalize.Value = localizer.GetHtml(resourceKey);
}
output.Attributes.Remove(attribute);
}
}
示例12: BootstrapProcessAsync
protected override async Task BootstrapProcessAsync(TagHelperContext context, TagHelperOutput output) {
output.TagName = "nav";
output.PreContent.AppendHtml(Size == SimpleSize.Default
? "<ul class=\"pagination\">"
: $"<ul class=\"pagination pagination-{Size.GetDescription()}\">");
ChildDetectionMode = true;
context.SetPaginationContext(this);
await output.GetChildContentAsync(true);
ChildDetectionMode = false;
if (!DisableAutoActive && Items.TrueForAll(pI => !pI.Active)) {
PaginationItemTagHelper activeItem = Items.FirstOrDefault(ItemHasCurrentUrl);
if (activeItem != null)
activeItem.Active = true;
}
for (var i = 0; i < Items.Count; i++)
if (string.IsNullOrEmpty(Items[i].Content))
Items[i].Content = (i + 1).ToString();
if (Items.Any(pI => pI.Active)) {
if (PrevHref == null)
PrevHref = Items.TakeWhile(pI => !pI.Active).LastOrDefault(pI => !pI.Disabled)?.Href;
if (NextHref == null)
NextHref = Items.SkipWhile(pI => !pI.Active).Skip(1).FirstOrDefault(pI => !pI.Disabled)?.Href;
}
DisableNext = NextHref == null || DisableNext.HasValue && DisableNext.Value == false;
DisablePrev = PrevHref == null || DisablePrev.HasValue && DisablePrev.Value == false;
output.PreContent.AppendHtml(
PaginationItemTagHelper.RenderItemTag(
"<span aria-hidden=\"true\">«</span>",
PrevHref, DisablePrev.Value, false,
PrevText ?? Ressources.Previous));
output.PostContent.AppendHtml(
PaginationItemTagHelper.RenderItemTag(
"<span aria-hidden=\"true\">»</span>",
NextHref, DisableNext.Value, false,
NextText ?? Ressources.Next));
if (MaxDisplayedItems > 0 && Items.Count > MaxDisplayedItems)
if (Items.Any(pI => pI.Active)) {
MaxDisplayedItems--;
List<PaginationItemTagHelper> itemsBeforeActive =
Items.TakeWhile(pI => !pI.Active).Reverse().ToList();
List<PaginationItemTagHelper> itemsAfterActive = Items.SkipWhile(pI => !pI.Active).Skip(1).ToList();
var itemsCountBeforeActive = (int) Math.Floor((decimal) MaxDisplayedItems/2);
var itemsCountAfterActive = (int) Math.Ceiling((decimal) MaxDisplayedItems/2);
if (itemsCountAfterActive > itemsAfterActive.Count)
itemsCountBeforeActive += itemsCountAfterActive - itemsAfterActive.Count;
else if (itemsCountBeforeActive > itemsBeforeActive.Count)
itemsCountAfterActive += itemsCountBeforeActive - itemsBeforeActive.Count;
foreach (PaginationItemTagHelper item in itemsBeforeActive.Skip(itemsCountBeforeActive))
item.RenderOutput = false;
foreach (PaginationItemTagHelper item in itemsAfterActive.Skip(itemsCountAfterActive))
item.RenderOutput = false;
}
else
foreach (PaginationItemTagHelper item in Items.Skip(MaxDisplayedItems))
item.RenderOutput = false;
foreach (PaginationItemTagHelper item in Items.Where(pI => pI.RenderOutput))
output.Content.AppendHtml(PaginationItemTagHelper.RenderItemTag(item));
}
示例13: ProcessAsync
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
output.TagName = null;
for (int i = 0; i < Count; i++)
{
output.Content.Append(await output.GetChildContentAsync());
}
}
示例14: ProcessAsync
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var childContent = await output.GetChildContentAsync();
// Find Urls in the content and replace them with their anchor tag equivalent.
output.Content.SetHtmlContent(Regex.Replace(
childContent.GetContent(),
@"\b(www\.)(\S+)\b",
"<a target=\"_blank\" href=\"http://$0\">$0</a>")); // www version
}
示例15: ProcessAsync
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "a"; // Replaces <email> with <a> tag
var content = await output.GetChildContentAsync();
var target = content.GetContent() + "@" + EmailDomain;
output.Attributes["href"] = "mailto:" + target;
output.Content.SetContent(target);
}