-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProviderSection.cs
59 lines (50 loc) · 1.31 KB
/
ProviderSection.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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Grammophone.Configuration
{
/// <summary>
/// Configuration section containing a 'providers' collection of
/// elements of type <typeparamref name="E"/> which supply instances of
/// type <typeparamref name="B"/>.
/// </summary>
/// <typeparam name="B">The base type of the instances being provided.</typeparam>
/// <typeparam name="E">The type of the providers configuration elements.</typeparam>
public class ProviderSection<B, E> : ConfigurationSection
where E : TypeElement<B>, new()
{
#region Private fields
private const string providersKey = "providers";
#endregion
#region Construction
/// <summary>
/// Create.
/// </summary>
public ProviderSection()
{
this[providersKey] = new NamedElementsCollection<E>();
}
#endregion
#region Public properties
/// <summary>
/// The
/// </summary>
[ConfigurationProperty(providersKey, IsDefaultCollection = false)]
public NamedElementsCollection<E> Providers
{
get
{
return (NamedElementsCollection<E>)this[providersKey];
}
set
{
if (value == null) throw new ArgumentNullException(nameof(value));
this[providersKey] = value;
}
}
#endregion
}
}