Merge pull request #364 from directhex/master
[mono.git] / mcs / class / System.Configuration / System.Configuration / AppSettingsSection.cs
index 046e2d5f453a26725129be2207c73179fb03b089..1008a0ae986c214146c513f2320112e183479032 100644 (file)
@@ -29,6 +29,7 @@
 
 #if NET_2_0
 using System;
+using System.ComponentModel;
 using System.Collections.Specialized;
 using System.Xml;
 using System.IO;
@@ -43,14 +44,10 @@ namespace System.Configuration {
 
                 static AppSettingsSection ()
                 {
-                        _propFile = new ConfigurationProperty ("file",
-                                                               typeof(string), 
-                                                               "", 
-                                                               ConfigurationPropertyOptions.None);
-                        _propSettings = new ConfigurationProperty ("",
-                                                                  typeof(KeyValueConfigurationCollection),
-                                                                  null, 
-                                                                  ConfigurationPropertyOptions.IsDefaultCollection);
+                        _propFile = new ConfigurationProperty ("file", typeof(string), "",
+                                                              new StringConverter(), null, ConfigurationPropertyOptions.None);
+                        _propSettings = new ConfigurationProperty ("", typeof(KeyValueConfigurationCollection), null, 
+                                                                  null, null, ConfigurationPropertyOptions.IsDefaultCollection);
 
                         _properties     = new ConfigurationPropertyCollection ();
 
@@ -67,7 +64,7 @@ namespace System.Configuration {
                        return Settings.IsModified ();
                }
 
-               [MonoTODO ("file path?  do we use a System.Configuration api for opening it?  do we keep it open?  do we open it writable?")]
+               [MonoInternalNote ("file path?  do we use a System.Configuration api for opening it?  do we keep it open?  do we open it writable?")]
                protected internal override void DeserializeElement (XmlReader reader, bool serializeCollectionKey)
                {
                        /* need to do this so we pick up the File attribute */
@@ -76,7 +73,7 @@ namespace System.Configuration {
                        if (File != "") {
                                try {
                                        Stream s = System.IO.File.OpenRead (File);
-                                       XmlReader subreader = new XmlTextReader (s);
+                                       XmlReader subreader = new ConfigXmlTextReader (s, File);
                                        base.DeserializeElement (subreader, serializeCollectionKey);
                                        s.Close ();
                                }
@@ -122,10 +119,19 @@ namespace System.Configuration {
                        }
                }
 
-               [MonoTODO]
                protected internal override object GetRuntimeObject ()
                {
-                       return base.GetRuntimeObject();
+                       KeyValueInternalCollection col = new KeyValueInternalCollection ();
+                               
+                       foreach (string key in Settings.AllKeys) {
+                               KeyValueConfigurationElement ele = Settings[key];
+                               col.Add (ele.Key, ele.Value);
+                       }
+                               
+                       if (!ConfigurationManager.ConfigurationSystem.SupportsUserConfig)
+                               col.SetReadOnly ();
+
+                       return col;
                }
        }
 }