-
Notifications
You must be signed in to change notification settings - Fork 0
/
SynonymsAttribute.cs
38 lines (34 loc) · 1.04 KB
/
SynonymsAttribute.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
/*
* SynonymsAttribute.cs
*
* Created: 2023-04-14-06:23:15
* Modified: 2023-10-01-07:32:58
*
* Author: David G. Moore, Jr. <david@dgmjr.io>
*
* Copyright © 2022 - 2023 David G. Moore, Jr., All Rights Reserved
* License: MIT (https://opensource.org/licenses/MIT)
*/
using System;
namespace System.ComponentModel.DataAnnotations;
/// <summary>
/// Attribute that stores an array of synonyms for a given value.
/// </summary>
[AttributeUsage(
AttributeTargets.Field
| AttributeTargets.Property
| AttributeTargets.Class
| AttributeTargets.Struct
| AttributeTargets.Enum
| AttributeTargets.Interface,
AllowMultiple = false
)]
public sealed class SynonymsAttribute(params string[] synonyms) : ValueAttribute<string[]>(synonyms)
{
public SynonymsAttribute(string synonyms)
: this(synonyms.Split(',')) { }
/// <summary>
/// Gets the array of synonyms stored in the base class's "Value" property.
/// </summary>
public string[] Synonyms => Value;
}