-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttributeBindingModel.cs
More file actions
76 lines (67 loc) · 3.76 KB
/
AttributeBindingModel.cs
File metadata and controls
76 lines (67 loc) · 3.76 KB
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
66
67
68
69
70
71
72
73
74
75
76
/*==============================================================================================================================
| Author Ignia, LLC
| Client Ignia, LLC
| Project Topics Library
\=============================================================================================================================*/
namespace OnTopic.Editor.AspNetCore.Models {
/*============================================================================================================================
| CLASS: ATTRIBUTE (BINDING MODEL)
\---------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Represents an instance of a generic attribute in the Topic Editor.
/// </summary>
public record AttributeBindingModel {
/*==========================================================================================================================
| CONSTRUCTOR
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Initializes a new instance of the <see cref="AttributeBindingModel"/> class.
/// </summary>
public AttributeBindingModel() : this("") {}
/// <summary>
/// Initializes a new instance of the <see cref="AttributeBindingModel"/> class.
/// </summary>
/// <param name="editorType">Optionally defines the type of attribute.</param>
public AttributeBindingModel(string editorType) {
if (String.IsNullOrWhiteSpace(editorType)) {
EditorType = GetType().Name.Replace("AttributeBindingModel", "", StringComparison.Ordinal);
}
else {
EditorType = editorType;
}
}
/*==========================================================================================================================
| KEY
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// The unique name associated with the specified attribute.
/// </summary>
public string Key { get; init; } = default!;
/*==========================================================================================================================
| EDITOR TYPE
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// The editor type associated with the attribute.
/// </summary>
public string EditorType { get; init; } = default!;
/*==========================================================================================================================
| VALUE
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// The value associated with the attribute.
/// </summary>
public string? Value { get; init; } = default!;
/*==========================================================================================================================
| GET VALUE
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Retrieves the value associated with the attribute.
/// </summary>
/// <remarks>
/// Unlike the <see cref="Value"/> property, which simply returns the literal value associated with the attribute, the
/// <see cref="GetValue()"/> method is intended to be overwritten by derived versions of the <see cref="AttributeBindingModel"/>
/// class, in order to provide specific serialization instructions.
/// </remarks>
public virtual string GetValue() => Value?? "";
} // Class
} // Namespace