2005-12-02 Chris Toshok <toshok@ximian.com>
[mono.git] / mcs / class / System.Configuration / System.Configuration / AppSettingsSection.cs
index f054fe54939b4885935d30b9bdd74aacdc9ca49a..8303998b489255da440b045736238d9c635c7005 100644 (file)
@@ -3,6 +3,7 @@
 //
 // Authors:
 //     Duncan Mak (duncan@ximian.com)
+//     Chris Toshok (toshok@ximian.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -37,7 +38,22 @@ namespace System.Configuration {
        public sealed class AppSettingsSection : ConfigurationSection
        {
                KeyValueConfigurationCollection values;
-               
+               const string configFile = "file";
+
+                private static ConfigurationPropertyCollection _properties;
+                private static readonly ConfigurationProperty _propFile;
+
+                static AppSettingsSection ()
+                {
+                        _properties     = new ConfigurationPropertyCollection ();
+                        _propFile = new ConfigurationProperty (configFile, 
+                                                               typeof(string), 
+                                                               "", 
+                                                               ConfigurationPropertyOptions.None);
+
+                        _properties.Add (_propFile);
+                }
+
                public AppSettingsSection ()
                {
                }
@@ -50,7 +66,10 @@ namespace System.Configuration {
                [MonoTODO ("Read file attribute")]
                protected internal override void DeserializeElement (XmlReader reader, bool serializeCollectionKey)
                {
-                       Settings.DeserializeElement (reader, serializeCollectionKey);
+                       if (File != "") {
+                               /* deserialize from the file */
+                               throw new NotImplementedException ();
+                       }
                }
 
                protected internal override void Reset (ConfigurationElement parentSection)
@@ -60,22 +79,25 @@ namespace System.Configuration {
                                Settings.Reset (psec.Settings);
                }
 
+               [MonoTODO]
                protected internal override string SerializeSection (
                        ConfigurationElement parent, string name, ConfigurationSaveMode mode)
                {
-                       AppSettingsSection psec = parent as AppSettingsSection;
-                       if (psec != null)
-                               return Settings.SerializeSection (psec.Settings, name, mode);
-                       else
-                               return Settings.SerializeSection (null, name, mode);
+                       if (File == "") {
+                               return base.SerializeSection (parent, name, mode);
+                       }
+                       else {
+                               throw new NotImplementedException ();
+                       }
                }
 
-               [MonoTODO]
+               [ConfigurationProperty ("file", DefaultValue = "")]
                public string File {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return (string)base [configFile]; }
+                       set { base [configFile] = value; }
                }
 
+               [ConfigurationProperty ("", Options = ConfigurationPropertyOptions.IsDefaultCollection)]
                public KeyValueConfigurationCollection Settings {
                        get {
                                if (values == null)
@@ -83,6 +105,18 @@ namespace System.Configuration {
                                return values;
                        }
                }
+
+               protected internal override ConfigurationPropertyCollection Properties {
+                       get {
+                               return _properties;
+                       }
+               }
+
+               [MonoTODO]
+               protected internal override object GetRuntimeObject ()
+               {
+                       return base.GetRuntimeObject();
+               }
        }
 }
 #endif