本文整理汇总了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;
}
示例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);
}