support configuration hierarchy merge
authorKonstantin Triger <kostat@mono-cvs.ximian.com>
Thu, 25 May 2006 15:38:34 +0000 (15:38 -0000)
committerKonstantin Triger <kostat@mono-cvs.ximian.com>
Thu, 25 May 2006 15:38:34 +0000 (15:38 -0000)
svn path=/branches/mainsoft/gh1.7/mcs/; revision=61111

mcs/class/System.Data/Mainsoft.Data.Configuration.jvm/ChangeLog [new file with mode: 0644]
mcs/class/System.Data/Mainsoft.Data.Configuration.jvm/ProvidersSectionHandler.cs

diff --git a/mcs/class/System.Data/Mainsoft.Data.Configuration.jvm/ChangeLog b/mcs/class/System.Data/Mainsoft.Data.Configuration.jvm/ChangeLog
new file mode 100644 (file)
index 0000000..c239f22
--- /dev/null
@@ -0,0 +1,3 @@
+2006-05-25  Konstantin Triger <kostat@mainsoft.com>
+
+       * ProvidersSectionHandler.cs: support configuration hierarchy merge.
\ No newline at end of file
index 17f6513e1ab2a40c8f651610123c42e49b6265e3..5ac952a9b57a4e59fb5dafd245f14137c365af97 100755 (executable)
@@ -77,8 +77,28 @@ namespace Mainsoft.Data.Configuration
                                Hashtable col = (Hashtable) handler.Create (parentProvider, null, child);
                                providers.Add(col);
                        }       
-                       if (parent != null && parent is ICollection)
-                               providers.AddRange((ICollection)parent);
+                       if (parent != null && parent is IList) {
+                               IList parentList = (IList)parent;
+                               for (int i = 0; i < parentList.Count; i++) {
+                                       Hashtable htParent = (Hashtable)parentList[i];
+                                       string parentId = (string)htParent["id"];
+                                       bool overriden = false;
+                                       for (int y = 0; y < providers.Count; y++) {
+                                               Hashtable htMe = (Hashtable)providers[y];
+                                               string myId = (string)htMe["id"];
+                                               if (String.CompareOrdinal(parentId,myId) == 0) {
+                                                       overriden = true;
+                                                       foreach (object key in htParent.Keys)
+                                                               if (!htMe.ContainsKey(key))
+                                                                       htMe[key] = htParent[key];
+                                                       break;
+                                               }
+                                       }
+
+                                       if (!overriden)
+                                               providers.Add(htParent);
+                               }
+                       }
 
                        return providers;
                }