Added Implementation of Create() method.
[mono.git] / mcs / class / System / System.Configuration / SingleTagSectionHandler.cs
1 //
2 // System.Configuration.SingleTagSectionHandler.cs
3 //
4 // Author:
5 //   Christopher Podurgiel (cpodurgiel@msn.com)
6 //
7 // (C) Chris Podurgiel
8 //
9
10 using System;
11 using System.Xml;
12 using System.Collections;
13
14
15 namespace System.Configuration
16 {
17         /// <summary>
18         /// Summary description for SingleTagSectionHandler.
19         /// </summary>
20         public class SingleTagSectionHandler : IConfigurationSectionHandler
21         {
22
23                 public SingleTagSectionHandler()
24                 {
25                         //
26                         // TODO: Add constructor logic here
27                         //
28                 }
29
30                 /// <summary>
31                 ///             Returns a collection of configuration section values.
32                 /// </summary>
33                 /// <param name="parent"></param>
34                 /// <param name="context"></param>
35                 /// <param name="section">The name of the configuration section.</param>
36                 /// <returns></returns>
37                 public object Create(object parent, object context, XmlNode section)
38                 {
39                         //FIXME: I'm not quite sure how to implement 'parent' or 'context'.
40                         //TODO: Add in proper Error Handling.
41
42                         //Get all of the ChildNodes in the XML section.
43                         if(section.HasChildNodes)
44                         {
45                                 throw (new ConfigurationException("Child Nodes not allowed."));
46                         }
47                         
48                         
49                         //Get the attributes for the childNode
50                         XmlAttributeCollection xmlAttributes = section.Attributes;
51
52                         Hashtable settingsCollection = new Hashtable();
53                         
54                         for(int i=0; i < xmlAttributes.Count; i++)
55                         {
56                                 settingsCollection.Add(xmlAttributes[i].Name, xmlAttributes[i].Value);
57                         }
58                         
59                         return settingsCollection;
60                 }
61         }
62 }