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


C# TagHelperOutput.RemoveRange方法代码示例

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


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

示例1: GetRouteValues

        // TODO: https://github.com/aspnet/Razor/issues/89 - We will not need this method once #89 is completed.
        private static Dictionary<string, object> GetRouteValues(
            TagHelperOutput output,
            IEnumerable<KeyValuePair<string, object>> routePrefixedAttributes)
        {
            Dictionary<string, object> routeValues = null;
            if (routePrefixedAttributes.Any())
            {
                // Prefixed values should be treated as bound attributes, remove them from the output.
                output.RemoveRange(routePrefixedAttributes);

                // Remove prefix from keys and convert all values to strings. HtmlString and similar classes are not
                // meaningful to routing.
                routeValues = routePrefixedAttributes.ToDictionary(
                    attribute => attribute.Key.Substring(RouteAttributePrefix.Length),
                    attribute => (object)attribute.Value.ToString());
            }

            return routeValues;
        }
开发者ID:AndersBillLinden,项目名称:Mvc,代码行数:20,代码来源:AnchorTagHelper.cs

示例2: RemoveRange_RemovesProvidedAttributes

        public void RemoveRange_RemovesProvidedAttributes()
        {
            // Arrange
            var tagHelperOutput = new TagHelperOutput(
                "p",
                attributes: new Dictionary<string, object>()
                {
                    { "route-Hello", "World" },
                    { "Route-I", "Am" }
                });
            var expectedAttribute = new KeyValuePair<string, object>("type", "btn");
            tagHelperOutput.Attributes.Add(expectedAttribute);
            var attributes = tagHelperOutput.FindPrefixedAttributes("route-");

            // Act
            tagHelperOutput.RemoveRange(attributes);

            // Assert
            var attribute = Assert.Single(tagHelperOutput.Attributes);
            Assert.Equal(expectedAttribute, attribute);
        }
开发者ID:AndersBillLinden,项目名称:Mvc,代码行数:21,代码来源:TagHelperOutputExtensionsTest.cs


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