-
Notifications
You must be signed in to change notification settings - Fork 0
/
GlossaryItem.cs
87 lines (76 loc) · 2.43 KB
/
GlossaryItem.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using PrimitiveExtensions;
namespace AbbreviationGlossary
{
public class GlossaryItem
{
private string _term;
private string _abbreviation;
private bool _isTermPreferred;
private bool _isPreferredTermValueSet;
public GlossaryItem()
{ }
public GlossaryItem(string term, string abbreviation, bool isPrimary)
{
Term = term;
Abbreviation = abbreviation;
IsTermPreferred = isPrimary;
}
public override string ToString()
{
return Term;
}
/// <summary>
/// Represents a spelled out word or phrase
/// </summary>
public string Term
{
get => _term;
set
{
if (_term.IsNullOrEmptyString())
{
_term = value;
}
else
{
throw new System.Exception("Cannot change a term or an abbreviation from the glossary. Consider removing this entry and adding a new one");
}
}
}
/// <summary>
/// Represents a shortened form of a word or phrase
/// </summary>
public string Abbreviation
{
get => _abbreviation;
set
{
if (_abbreviation.IsNullOrEmptyString())
{
_abbreviation = value;
}
else
{
throw new System.Exception("Cannot change a term or an abbreviation from the glossary. Consider removing this entry and adding a new one");
}
}
}
/// <summary>
/// When true, signifies that a glossary item will be used for both ExpandAbbreviation() and Abbreviate() methods. If false the glossary item will be used only for Abbreviate() methods.
/// </summary>
public bool IsTermPreferred { get => _isTermPreferred;
set
{
if (!_isPreferredTermValueSet)
{
_isPreferredTermValueSet = true;
_isTermPreferred = value;
}
else
{
throw new System.Exception("Cannot change a status once set. Consider removing this entry and adding a new one");
}
}
}
}
}