-
Notifications
You must be signed in to change notification settings - Fork 1
/
NamedElement.cs
54 lines (45 loc) · 1 KB
/
NamedElement.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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Grammophone.Configuration
{
/// <summary>
/// Base class for elements contained in <see cref="NamedElementsCollection{E}"/>.
/// </summary>
public abstract class NamedElement : ConfigurationElement
{
#region Private fields
private const string nameKey = "name";
#endregion
#region Construction
/// <summary>
/// Create.
/// </summary>
public NamedElement()
{
this[nameKey] = String.Empty;
}
#endregion
#region Public properties
/// <summary>
/// The name of the element, serving as a key for the containing element collection.
/// </summary>
[ConfigurationProperty(nameKey, IsRequired = true, IsKey = true)]
public string Name
{
get
{
return (string)this[nameKey];
}
set
{
if (value == null) throw new ArgumentNullException(nameof(value));
this[nameKey] = value;
}
}
#endregion
}
}