Merge pull request #364 from directhex/master
[mono.git] / mcs / class / System.Configuration / System.Configuration / KeyValueConfigurationElement.cs
index 3c14dceb1bf55572ed55a3345b423f36acd8c826..66476dd0bcbbb14260df4570cfa6951defd68b51 100644 (file)
@@ -34,30 +34,44 @@ namespace System.Configuration
 {
        public class KeyValueConfigurationElement: ConfigurationElement
        {
-               ConfigurationPropertyCollection properties;
-               
+               static ConfigurationProperty keyProp;
+               static ConfigurationProperty valueProp;
+               static ConfigurationPropertyCollection properties;
+
+               static KeyValueConfigurationElement ()
+               {
+                       keyProp = new ConfigurationProperty ("key", typeof (string), "", ConfigurationPropertyOptions.IsKey);
+                       valueProp = new ConfigurationProperty ("value", typeof (string), "");
+
+                       properties = new ConfigurationPropertyCollection ();
+                       properties.Add (keyProp);
+                       properties.Add (valueProp);
+               }
+
                internal KeyValueConfigurationElement ()
                {
                }
-               
+
                public KeyValueConfigurationElement (string key, string value)
                {
+                       this[keyProp] = key;
+                       this[valueProp] = value;
                }
                
+               [ConfigurationProperty ("key", DefaultValue = "", Options = ConfigurationPropertyOptions.IsKey)]
                public string Key {
-                       get { return (string) this["key"]; }
+                       get { return (string) this[keyProp]; }
                }
                
+               [ConfigurationProperty ("value", DefaultValue = "")]
                public string Value {
-                       get { return (string) this["value"]; }
-                       set { this ["value"] = value; }
+                       get { return (string) this[valueProp]; }
+                       set { this [valueProp] = value; }
                }
-               
+
+               [MonoTODO]
                protected internal override void Init ()
                {
-                       properties = new ConfigurationPropertyCollection ();
-                       properties.Add (new ConfigurationProperty ("key", typeof(string), string.Empty, ConfigurationPropertyOptions.IsKey));
-                       properties.Add (new ConfigurationProperty ("value", typeof(string), string.Empty));
                }
                
                protected internal override ConfigurationPropertyCollection Properties {