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


C# DefaultTagHelperContent.AppendFormat方法代码示例

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


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

示例1: ProcessAsync

 public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     if (ShowDismiss)
     {
         output.PreContent.AppendFormat(@"<button type='button' class='btn btn-default' data-dismiss='modal'>{0}</button>", DismissText);
     }
     var childContent = await output.GetChildContentAsync();
     var footerContent = new DefaultTagHelperContent();
     if (ShowDismiss)
     {
         footerContent.AppendFormat(@"<button type='button' class='btn btn-default' data-dismiss='modal'>{0}</button>", DismissText);
     }
     footerContent.AppendHtml(childContent);
     var modalContext = (ModalContext)context.Items[typeof(ModalTagHelper)];
     modalContext.Footer = footerContent;
     output.SuppressOutput();
 }
开发者ID:dpaquette,项目名称:TagHelperSamples,代码行数:17,代码来源:ModalFooterTagHelper.cs

示例2: CanAppendDefaultTagHelperContent

        public void CanAppendDefaultTagHelperContent()
        {
            // Arrange
            var tagHelperContent = new DefaultTagHelperContent();
            var helloWorldContent = new DefaultTagHelperContent();
            helloWorldContent.SetContent("HelloWorld");
            var expected = "Content was HtmlEncode[[HelloWorld]]";

            // Act
            tagHelperContent.AppendFormat("Content was {0}", helloWorldContent);

            // Assert
            Assert.Equal(expected, tagHelperContent.GetContent(new HtmlTestEncoder()));
        }
开发者ID:x-strong,项目名称:Razor,代码行数:14,代码来源:DefaultTagHelperContentTest.cs

示例3: CanAppendFormat_WithCulture

        public void CanAppendFormat_WithCulture()
        {
            // Arrange
            var tagHelperContent = new DefaultTagHelperContent();

            // Act
            tagHelperContent.AppendFormat(
                CultureInfo.InvariantCulture,
                "Numbers in InvariantCulture - {0:N} {1} {2} {3}!",
                1.1,
                2.98,
                145.82,
                32.86);

            // Assert
            Assert.Equal(
                "Numbers in InvariantCulture - HtmlEncode[[1.10]] HtmlEncode[[2.98]] " +
                    "HtmlEncode[[145.82]] HtmlEncode[[32.86]]!",
                tagHelperContent.GetContent(new HtmlTestEncoder()));
        }
开发者ID:x-strong,项目名称:Razor,代码行数:20,代码来源:DefaultTagHelperContentTest.cs

示例4: CanAppendFormatContent

        public void CanAppendFormatContent()
        {
            // Arrange
            var tagHelperContent = new DefaultTagHelperContent();

            // Act
            tagHelperContent.AppendFormat("{0} {1} {2} {3}!", "First", "Second", "Third", "Fourth");

            // Assert
            Assert.Equal(
                "HtmlEncode[[First]] HtmlEncode[[Second]] HtmlEncode[[Third]] HtmlEncode[[Fourth]]!",
                tagHelperContent.GetContent(new HtmlTestEncoder()));
        }
开发者ID:x-strong,项目名称:Razor,代码行数:13,代码来源:DefaultTagHelperContentTest.cs


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