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


C# TagHelperOutput.GetChildContentAsync方法代码示例

本文整理汇总了C#中Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput.GetChildContentAsync方法的典型用法代码示例。如果您正苦于以下问题:C# TagHelperOutput.GetChildContentAsync方法的具体用法?C# TagHelperOutput.GetChildContentAsync怎么用?C# TagHelperOutput.GetChildContentAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput的用法示例。


在下文中一共展示了TagHelperOutput.GetChildContentAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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));
            }

            IHtmlContent content = null;

            // Create a cancellation token that will be used
            // to release the task from the memory cache.
            var tokenSource = new CancellationTokenSource();

            if (Enabled)
            {
                var cacheKey = new CacheTagKey(this);

                content = await _distributedCacheService.ProcessContentAsync(output, cacheKey, GetDistributedCacheEntryOptions());
            }
            else
            {
                content = await output.GetChildContentAsync();
            }

            // Clear the contents of the "cache" element since we don't want to render it.
            output.SuppressOutput();

            output.Content.SetHtmlContent(content);
        }
开发者ID:cemalshukriev,项目名称:Mvc,代码行数:35,代码来源:DistributedCacheTagHelper.cs

示例2: 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:dpaquette,项目名称:TagHelperSamples,代码行数:7,代码来源:ModalBodyTagHelper.cs

示例3: 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.AppendHtml(labelBuilder);
            }
            output.Content.AppendHtml(contentDiv);

            base.Process(context, output);
        }
开发者ID:CormacdeBarra,项目名称:steelcap,代码行数:31,代码来源:FormGroupTagHelper.cs

示例4: GetContent

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

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

示例5: 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 = new FormContext();
        }
开发者ID:cemalshukriev,项目名称:Mvc,代码行数:28,代码来源:RenderAtEndOfFormTagHelper.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.AppendHtml(WidgetBoxHeaderHelper.GetFullHeader(Title, IsCollapsible));
                var widgetBodyDiv = WidgetBoxBodyHelper.GetFullBodyInternals(Padding, innerHtml);
                output.Content.AppendHtml(widgetBodyDiv);
            }
            else
            {
                // user is doing the hardwork themselves
                output.Content.AppendHtml(innerHtml);
            }
            
            base.Process(context, output);
        }
开发者ID:CormacdeBarra,项目名称:steelcap,代码行数:27,代码来源:WidgetBoxHelper.cs

示例7: GetChildContentAsync_CallsGetChildContentAsync

        public async Task GetChildContentAsync_CallsGetChildContentAsync()
        {
            // Arrange
            bool? passedUseCacheResult = null;
            HtmlEncoder passedEncoder = null;
            var content = new DefaultTagHelperContent();
            var output = new TagHelperOutput(
                tagName: "tag",
                attributes: new TagHelperAttributeList(),
                getChildContentAsync: (useCachedResult, encoder) =>
                {
                    passedUseCacheResult = useCachedResult;
                    passedEncoder = encoder;
                    return Task.FromResult<TagHelperContent>(content);
                });

            // Act
            var result = await output.GetChildContentAsync();

            // Assert
            Assert.True(passedUseCacheResult.HasValue);
            Assert.True(passedUseCacheResult.Value);
            Assert.Null(passedEncoder);
            Assert.Same(content, result);
        }
开发者ID:cjqian,项目名称:Razor,代码行数:25,代码来源:TagHelperOutputTest.cs

示例8: ProcessAsync

 public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     output.TagName = "a";
     var content = await output.GetChildContentAsync();
     var address = content.GetContent() + "@" + _configuration.Domain;
     output.Attributes.SetAttribute("href", "mailto:" + address);
     output.Content.SetContent(address);
 }
开发者ID:ebt-techtalk,项目名称:asp.net,代码行数:8,代码来源:EmailTagHelper.cs

示例9: 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.SetAttribute("href", "mailto:" + target);
     output.Content.SetContent(target);
 }
开发者ID:CIPop,项目名称:Docs,代码行数:8,代码来源:EmailTagHelper.cs

示例10: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var defaultContent = await output.GetChildContentAsync();

            output.Content
                .SetHtmlContent("Default encoder: ")
                .AppendHtml(defaultContent);
            output.TagName = "pre";
        }
开发者ID:ymd1223,项目名称:Mvc,代码行数:9,代码来源:DefaultEncoderTagHelper.cs

示例11: 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(?:https?://)(\S+)\b",
           "<a target=\"_blank\" href=\"$0\">$0</a>"));  // http link version}
 }
开发者ID:CIPop,项目名称:Docs,代码行数:9,代码来源:z1AutoLinker.cs

示例12: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var content = await output.GetChildContentAsync();
            var collectionContext = (InputCollectionContext)context.Items[typeof(InputCollectionTagHelper)];

            var localContext = new InputCollectionItemContext() { Label = Label, Content = content };

            collectionContext.Items.Add(localContext);
            output.SuppressOutput();
        }
开发者ID:iKadmium,项目名称:kadmium-osc-dmx-dotnet,代码行数:10,代码来源:InputCollectionItemTagHelper.cs

示例13: 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.AppendHtml(Regex.Replace(
                childContent.GetContent(),
                @"\b(?:https?://|www\.)(\S+)\b",
                "<strong><a target=\"_blank\" href=\"http://$0\">$0</a></strong>"));
        }
开发者ID:cemalshukriev,项目名称:Mvc,代码行数:10,代码来源:AutoLinkerTagHelper.cs

示例14: ProcessAsync

       public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
       {
           var childContent = output.Content.IsModified ? output.Content.GetContent() : 
               (await output.GetChildContentAsync()).GetContent();
 
           // Find Urls in the content and replace them with their anchor tag equivalent.
           output.Content.SetHtmlContent(Regex.Replace(
                childContent,
                @"\b(www\.)(\S+)\b",
                "<a target=\"_blank\" href=\"http://$0\">$0</a>"));  // www version
       }
开发者ID:CIPop,项目名称:Docs,代码行数:11,代码来源:z2AutoLinkerCopy.cs

示例15: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var nullContent = await output.GetChildContentAsync(NullHtmlEncoder.Default);

            // Note this is very unsafe. Should always post-process content that may not be fully HTML encoded before
            // writing it into a response. Here for example, could pass SetContent() a string and that would be
            // HTML encoded later.
            output.PostContent
                .SetHtmlContent("<br />Null encoder: ")
                .AppendHtml(nullContent);
        }
开发者ID:ymd1223,项目名称:Mvc,代码行数:11,代码来源:NullEncoderTagHelper.cs


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