renamed TagNameAttribute to HtmlElementNameAttribute
This commit is contained in:
parent
e30e74dc5a
commit
891dfa5e3e
|
|
@ -81,17 +81,17 @@ namespace Microsoft.AspNet.Razor.Runtime
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parameter {0} must not contain null tag names.
|
/// Parameter {0} must not contain null tag names.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string TagNameAttribute_AdditionalTagsCannotContainNull
|
internal static string HtmlElementNameAttribute_AdditionalTagsCannotContainNull
|
||||||
{
|
{
|
||||||
get { return GetString("TagNameAttribute_AdditionalTagsCannotContainNull"); }
|
get { return GetString("HtmlElementNameAttribute_AdditionalTagsCannotContainNull"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parameter {0} must not contain null tag names.
|
/// Parameter {0} must not contain null tag names.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string FormatTagNameAttribute_AdditionalTagsCannotContainNull(object p0)
|
internal static string FormatHtmlElementNameAttribute_AdditionalTagsCannotContainNull(object p0)
|
||||||
{
|
{
|
||||||
return string.Format(CultureInfo.CurrentCulture, GetString("TagNameAttribute_AdditionalTagsCannotContainNull"), p0);
|
return string.Format(CultureInfo.CurrentCulture, GetString("HtmlElementNameAttribute_AdditionalTagsCannotContainNull"), p0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@
|
||||||
<data name="ScopeManager_EndCannotBeCalledWithoutACallToBegin" xml:space="preserve">
|
<data name="ScopeManager_EndCannotBeCalledWithoutACallToBegin" xml:space="preserve">
|
||||||
<value>Must call '{2}.{1}' before calling '{2}.{0}'.</value>
|
<value>Must call '{2}.{1}' before calling '{2}.{0}'.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TagNameAttribute_AdditionalTagsCannotContainNull" xml:space="preserve">
|
<data name="HtmlElementNameAttribute_AdditionalTagsCannotContainNull" xml:space="preserve">
|
||||||
<value>Parameter {0} must not contain null tag names.</value>
|
<value>Parameter {0} must not contain null tag names.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ArgumentCannotBeNullOrEmpty" xml:space="preserve">
|
<data name="ArgumentCannotBeNullOrEmpty" xml:space="preserve">
|
||||||
|
|
|
||||||
|
|
@ -11,29 +11,29 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
||||||
/// Used to override a <see cref="ITagHelper"/>'s default tag name target.
|
/// Used to override a <see cref="ITagHelper"/>'s default tag name target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
|
||||||
public sealed class TagNameAttribute : Attribute
|
public sealed class HtmlElementNameAttribute : Attribute
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Instantiates a new instance of the <see cref="TagNameAttribute"/> class.
|
/// Instantiates a new instance of the <see cref="HtmlElementNameAttribute"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tag">The HTML tag name for the <see cref="TagHelper"/> to target.</param>
|
/// <param name="tag">The HTML tag name for the <see cref="TagHelper"/> to target.</param>
|
||||||
public TagNameAttribute([NotNull] string tag)
|
public HtmlElementNameAttribute([NotNull] string tag)
|
||||||
{
|
{
|
||||||
Tags = new[] { tag };
|
Tags = new[] { tag };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Instantiates a new instance of the <see cref="TagNameAttribute"/> class.
|
/// Instantiates a new instance of the <see cref="HtmlElementNameAttribute"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tag">The HTML tag name for the <see cref="TagHelper"/> to target.</param>
|
/// <param name="tag">The HTML tag name for the <see cref="TagHelper"/> to target.</param>
|
||||||
/// <param name="additionalTags">Additional HTML tag names for the <see cref="TagHelper"/> to target.</param>
|
/// <param name="additionalTags">Additional HTML tag names for the <see cref="TagHelper"/> to target.</param>
|
||||||
public TagNameAttribute([NotNull] string tag, [NotNull] params string[] additionalTags)
|
public HtmlElementNameAttribute([NotNull] string tag, [NotNull] params string[] additionalTags)
|
||||||
{
|
{
|
||||||
if (additionalTags.Contains(null))
|
if (additionalTags.Contains(null))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(
|
throw new ArgumentNullException(
|
||||||
nameof(additionalTags),
|
nameof(additionalTags),
|
||||||
Resources.FormatTagNameAttribute_AdditionalTagsCannotContainNull(nameof(additionalTags)));
|
Resources.FormatHtmlElementNameAttribute_AdditionalTagsCannotContainNull(nameof(additionalTags)));
|
||||||
};
|
};
|
||||||
|
|
||||||
var allTags = new List<string>(additionalTags);
|
var allTags = new List<string>(additionalTags);
|
||||||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
||||||
private static IEnumerable<string> GetTagNames(Type tagHelperType)
|
private static IEnumerable<string> GetTagNames(Type tagHelperType)
|
||||||
{
|
{
|
||||||
var typeInfo = tagHelperType.GetTypeInfo();
|
var typeInfo = tagHelperType.GetTypeInfo();
|
||||||
var attributes = typeInfo.GetCustomAttributes<TagNameAttribute>(inherit: false);
|
var attributes = typeInfo.GetCustomAttributes<HtmlElementNameAttribute>(inherit: false);
|
||||||
|
|
||||||
// If there isn't an attribute specifying the tag name derive it from the name
|
// If there isn't an attribute specifying the tag name derive it from the name
|
||||||
if (!attributes.Any())
|
if (!attributes.Any())
|
||||||
|
|
|
||||||
|
|
@ -372,7 +372,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[TagName("p", "div")]
|
[HtmlElementName("p", "div")]
|
||||||
private class MultiTagTagHelper
|
private class MultiTagTagHelper
|
||||||
{
|
{
|
||||||
public string ValidAttribute { get; set; }
|
public string ValidAttribute { get; set; }
|
||||||
|
|
@ -382,18 +382,18 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[TagName("p", "p", "div", "div")]
|
[HtmlElementName("p", "p", "div", "div")]
|
||||||
private class DuplicateTagNameTagHelper
|
private class DuplicateTagNameTagHelper
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[TagName("data-condition")]
|
[HtmlElementName("data-condition")]
|
||||||
private class OverrideNameTagHelper
|
private class OverrideNameTagHelper
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[TagName("span")]
|
[HtmlElementName("span")]
|
||||||
[TagName("div", "p")]
|
[HtmlElementName("div", "p")]
|
||||||
private class MultipleAttributeTagHelper
|
private class MultipleAttributeTagHelper
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue