Merge pull request #364 from directhex/master
[mono.git] / mcs / class / System.Configuration / System.Configuration / AppSettingsSection.cs
index 248240297dde5dccd3e31631c55397b3d7386c66..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;
@@ -44,7 +45,7 @@ namespace System.Configuration {
                 static AppSettingsSection ()
                 {
                         _propFile = new ConfigurationProperty ("file", typeof(string), "",
-                                                              null, null, ConfigurationPropertyOptions.None);
+                                                              new StringConverter(), null, ConfigurationPropertyOptions.None);
                         _propSettings = new ConfigurationProperty ("", typeof(KeyValueConfigurationCollection), null, 
                                                                   null, null, ConfigurationPropertyOptions.IsDefaultCollection);
 
@@ -63,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 */
@@ -72,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 ();
                                }
@@ -118,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;
                }
        }
 }