-
Notifications
You must be signed in to change notification settings - Fork 0
/
GuidAttribute.cs
40 lines (37 loc) · 1.15 KB
/
GuidAttribute.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
/*
* GuidAttribute.cs
*
* Created: 2022-10-19-05:58:09
* Modified: 2023-10-01-07:32:13
*
* Author: David G. Moore, Jr. <[email protected]>
*
* Copyright © 2022 - 2023 David G. Moore, Jr., All Rights Reserved
* License: MIT (https://opensource.org/licenses/MIT)
*/
namespace System.ComponentModel.DataAnnotations;
/// <summary>
/// A class that represents a Guid attribute.
/// </summary>
[AttributeUsage(
AttributeTargets.Class
| AttributeTargets.Struct
| AttributeTargets.Property
| AttributeTargets.Field,
Inherited = true,
AllowMultiple = false
)]
public sealed class GuidAttribute(string guid) : ValueAttribute<guid>(System.Guid.Parse(guid))
{
/// <summary>
/// Initializes a new instance of the <see cref="GuidAttribute"/> class
/// using the specified <see cref="guid" /> value.
/// </summary>
/// <param name="guid">A GUID value.</param>
public GuidAttribute(guid guid)
: this(guid.ToString()) { }
/// <summary>
/// Gets the GUID value represented by the current <see cref="GuidAttribute"/>.
/// </summary>
public guid Guid => Value;
}