/
BindElementAttribute.cs
65 lines (56 loc) · 2.39 KB
/
BindElementAttribute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
namespace Microsoft.AspNetCore.Components
{
/// <summary>
/// Configures options for binding specific element types.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class BindElementAttribute : Attribute
{
/// <summary>
/// Constructs an instance of <see cref="BindElementAttribute"/>.
/// </summary>
/// <param name="element">The tag name of the element.</param>
/// <param name="suffix">The suffix value. For example, set this to <c>value</c> for <c>bind-value</c>, or set this to <see langword="null" /> for <c>bind</c>.</param>
/// <param name="valueAttribute">The name of the value attribute to be bound.</param>
/// <param name="changeAttribute">The name of an attribute that will register an associated change event.</param>
public BindElementAttribute(string element, string? suffix, string valueAttribute, string changeAttribute)
{
if (element == null)
{
throw new ArgumentNullException(nameof(element));
}
if (valueAttribute == null)
{
throw new ArgumentNullException(nameof(valueAttribute));
}
if (changeAttribute == null)
{
throw new ArgumentNullException(nameof(changeAttribute));
}
Element = element;
ValueAttribute = valueAttribute;
ChangeAttribute = changeAttribute;
Suffix = suffix;
}
/// <summary>
/// Gets the tag name of the element.
/// </summary>
public string Element { get; }
/// <summary>
/// Gets the suffix value.
/// For example, this will be <c>value</c> to mean <c>bind-value</c>, or <see langword="null" /> to mean <c>bind</c>.
/// </summary>
public string? Suffix { get; }
/// <summary>
/// Gets the name of the value attribute to be bound.
/// </summary>
public string ValueAttribute { get; }
/// <summary>
/// Gets the name of an attribute that will register an associated change event.
/// </summary>
public string ChangeAttribute { get; }
}
}