/
SingleTagSectionHandler.cs
49 lines (40 loc) · 1.42 KB
/
SingleTagSectionHandler.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections;
using System.Xml;
namespace System.Configuration
{
/**
* Single-tag dictionary config factory
*
* Use for tags of the form: <MySingleTag key1="value1" ... keyN="valueN"/>
*/
public class SingleTagSectionHandler : IConfigurationSectionHandler
{
/**
* Create
*
* Given a partially composed config object (possibly null)
* and some input from the config system, return a
* further partially composed config object
*/
public virtual object Create(object parent, object context, XmlNode section)
{
Hashtable result;
// start result off as a shallow clone of the parent
if (parent == null)
result = new Hashtable();
else
result = new Hashtable((IDictionary)parent);
// verify that there are no children
HandlerBase.CheckForChildNodes(section);
// iterate through each XML section in order and apply the directives
foreach (XmlAttribute attribute in section.Attributes)
{
// handle name-value pairs
result[attribute.Name] = attribute.Value;
}
return result;
}
}
}