当前位置: 首页>>代码示例>>C#>>正文


C# TagHelperOutput.GetChildContentAsync方法代码示例

本文整理汇总了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);
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:8,代码来源:ListGroupTagHelper.cs

示例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);
        }
开发者ID:neutmute,项目名称:steelcap,代码行数:31,代码来源:FormGroupTagHelper.cs

示例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;
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:27,代码来源:RenderAtEndOfFormTagHelper.cs

示例4: GetContent

        private async Task<string> GetContent(TagHelperOutput output)
        {
            if (Content == null)
                return (await output.GetChildContentAsync()).GetContent();

            return Content.Model?.ToString();
        }
开发者ID:candoumbe,项目名称:TagHelperSamples,代码行数:7,代码来源:MarkdownTagHelper.cs

示例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());
        }
开发者ID:RR-Studio,项目名称:RealEstateCrm,代码行数:27,代码来源:UiListItem.cs

示例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);
        }
开发者ID:neutmute,项目名称:steelcap,代码行数:27,代码来源:WidgetBoxHelper.cs

示例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();
 }
开发者ID:candoumbe,项目名称:TagHelperSamples,代码行数:7,代码来源:ModalBodyTagHelper.cs

示例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)));
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:7,代码来源:HiddenTagHelper.cs

示例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;
        }
开发者ID:phinq19,项目名称:git_example,代码行数:28,代码来源:RenderAtEndOfFormTagHelper.cs

示例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);
        }
开发者ID:NTaylorMullen,项目名称:RedisCacheTagHelper,代码行数:28,代码来源:RedisCacheTagHelper.cs

示例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);
            }
        }
开发者ID:leloulight,项目名称:Entropy,代码行数:30,代码来源:LocalizationTagHelper.cs

示例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\">&laquo;</span>",
                                                                        PrevHref, DisablePrev.Value, false,
                                                                        PrevText ?? Ressources.Previous));
     output.PostContent.AppendHtml(
                                   PaginationItemTagHelper.RenderItemTag(
                                                                         "<span aria-hidden=\"true\">&raquo;</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));
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:58,代码来源:PaginationTagHelper.cs

示例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());
            }
        }
开发者ID:AngelinaT,项目名称:WebCampTrainingKit,代码行数:9,代码来源:RepeatTagHelper.cs

示例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
		}
开发者ID:hakenr,项目名称:Mvc6TagHelpersViewComponentsDemo,代码行数:9,代码来源:AutoLinkerWwwTagHelper.cs

示例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);
		}
开发者ID:hakenr,项目名称:Mvc6TagHelpersViewComponentsDemo,代码行数:10,代码来源:EmailTagHelper.cs


注:本文中的Microsoft.AspNet.Razor.TagHelpers.TagHelperOutput.GetChildContentAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。