Merge pull request #644 from knocte/connstrings
[mono.git] / mcs / class / System.Configuration / System.Configuration / ConfigurationRemoveElement.cs
index bb5fb62b42d8f468de50a5e5c5bcc25745c55901..452c483d18a85ddc0fc3a810031c8ea4a9c73594 100644 (file)
 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
 //
 
-#if NET_2_0
-
 using System;
 using System.ComponentModel;
 using System.Configuration;
 
 namespace System.Configuration
 {
-       internal sealed class ConfigurationRemoveElement : ConfigurationElement
+       partial class ConfigurationElementCollection
        {
-               ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
-               string _name = "";
-
-               internal ConfigurationRemoveElement (ConfigurationElement origElement)
+               sealed class ConfigurationRemoveElement : ConfigurationElement
                {
-                       foreach (ConfigurationProperty p in origElement.Properties)
-                               if (p.IsKey)
+                       readonly ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection ();
+                       readonly ConfigurationElement _origElement;
+                       readonly ConfigurationElementCollection _origCollection;
+
+                       internal ConfigurationRemoveElement (ConfigurationElement origElement, ConfigurationElementCollection origCollection)
+                       {
+                               _origElement = origElement;
+                               _origCollection = origCollection;
+
+                               foreach (ConfigurationProperty p in origElement.Properties)
+                                       if (p.IsKey) {
+                                               properties.Add (p);
+                                       }
+                       }
+
+                       internal object KeyValue
+                       {
+                               get
                                {
-                                       properties.Add(p);
-                                       _name = p.Name;
-                               }
-               }
+                                       foreach (ConfigurationProperty p in Properties)
+                                               _origElement [p] = this [p];
 
-               internal object KeyValue
-               {
-                       get { return base [_name]; }
-               }
+                                       return _origCollection.GetElementKey (_origElement);
+                               }
+                       }
 
-               protected internal override ConfigurationPropertyCollection Properties 
-               {
-                       get { return properties; }
+                       protected internal override ConfigurationPropertyCollection Properties
+                       {
+                               get { return properties; }
+                       }
                }
        }
 }
-
-#endif 
\ No newline at end of file