-
Notifications
You must be signed in to change notification settings - Fork 9
/
SaslConfiguration.cs
175 lines (162 loc) · 5.15 KB
/
SaslConfiguration.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
using System.Configuration;
namespace S22.Sasl {
/// <summary>
/// Represents the sasl section within a configuration
/// file.
/// </summary>
public class SaslConfigurationSection : ConfigurationSection {
/// <summary>
/// The saslProviders section contains a collection of
/// saslProvider elements.
/// </summary>
[ConfigurationProperty("saslProviders", IsRequired = false,
IsKey = false, IsDefaultCollection = false)]
public SaslProviderCollection SaslProviders {
get {
return ((SaslProviderCollection) base["saslProviders"]);
}
set {
base["saslProviders"] = value;
}
}
}
/// <summary>
/// Represents a saslProvider configuration element within the
/// saslProviders section of a configuration file.
/// </summary>
[ConfigurationCollection(typeof(SaslProvider),
CollectionType=ConfigurationElementCollectionType.BasicMapAlternate)]
public class SaslProviderCollection : ConfigurationElementCollection {
/// <summary>
/// The name of the configuration element.
/// </summary>
internal const string PropertyName = "saslProvider";
/// <summary>
/// Gets the name used to identify this collection of elements
/// in the configuration file.
/// </summary>
protected override string ElementName {
get { return PropertyName; }
}
/// <summary>
/// Returns the SaslProvider instance for the saslProvider
/// element with the specified name.
/// </summary>
/// <param name="name">The name of the saslProvider element to
/// retrieve.</param>
/// <returns>The SaslProvider instance with the specified name
/// or null.</returns>
public new SaslProvider this[string name] {
get {
return (SaslProvider) BaseGet(name);
}
}
/// <summary>
/// Returns the SaslProvider instance for the saslProvider
/// element at the specified index.
/// </summary>
/// <param name="index">The index of the saslProvider element
/// to retrieve.</param>
/// <returns>The SaslProvider instance with the specified
/// index.</returns>
/// <exception cref="ConfigurationErrorsException">Thrown if the
/// index is less than 0 or if there is no SaslProvider instance
/// at the specified index.</exception>
public SaslProvider this[int index] {
get {
return (SaslProvider) BaseGet(index);
}
}
/// <summary>
/// Gets the collection type of the SaslProviderCollection.
/// </summary>
public override ConfigurationElementCollectionType CollectionType {
get {
return ConfigurationElementCollectionType.BasicMapAlternate;
}
}
/// <summary>
/// Indicates whether the specified System.Configuration.ConfigurationElement
/// exists in the SaslProviderCollection.
/// </summary>
/// <param name="elementName">The name of the element to verify.</param>
/// <returns>Returns true if the element exists in the collection,
/// otherwise false.</returns>
protected override bool IsElementName(string elementName) {
return elementName == PropertyName;
}
/// <summary>
/// Creates a new instance of the SaslProvider class.
/// </summary>
/// <returns>A new instance of the SaslProvider class.</returns>
protected override ConfigurationElement CreateNewElement() {
return new SaslProvider();
}
/// <summary>
/// Gets the element key for the specified SaslProvider element.
/// </summary>
/// <param name="element">A SaslProvider element to retrieve the
/// element key for.</param>
/// <returns>The unique element key of the specified SaslProvider
/// instance.</returns>
protected override object GetElementKey(ConfigurationElement element) {
return ((SaslProvider) element).Name;
}
}
/// <summary>
/// Represents a saslProvider section within the saslProviders
/// section of a configuration file.
/// </summary>
public class SaslProvider : ConfigurationSection {
/// <summary>
/// The name of the saslProvider. This attribute must be unique in
/// that no two saslProvider elements exists that have the same
/// name attribute.
/// </summary>
[ConfigurationProperty("name", IsRequired = true)]
public string Name {
get {
return (string) base["name"];
}
set {
base["name"] = value;
}
}
/// <summary>
/// The type name of the SaslMechanism exposed by the
/// saslProvider.
/// </summary>
[ConfigurationProperty("type", IsRequired = true)]
public string Type {
get {
return (string) base["type"];
}
set {
base["type"] = value;
}
}
/// <summary>
/// Retrieves the setting with the specified name for this saslProvider.
/// </summary>
/// <param name="name">The name of the setting to retrieve.</param>
/// <returns>The value of the setting with the specified name or null
/// if the setting could not be found.</returns>
public new string this[string name] {
get {
if (Settings[name] != null)
return Settings[name].Value;
return null;
}
}
/// <summary>
/// Represents a collection of arbitrary name-value pairs which can be
/// added to the saslProvider element.
/// </summary>
[ConfigurationProperty("", IsDefaultCollection = true)]
public NameValueConfigurationCollection Settings {
get {
return (NameValueConfigurationCollection) base[""];
}
}
}
}