Author: mhabersack
Date: 2006-11-28 15:26:56 -0500 (Tue, 28 Nov 2006)
New Revision: 68615

Modified:
   trunk/mcs/class/System.Configuration/System.Configuration/ChangeLog
   trunk/mcs/class/System.Configuration/System.Configuration/ConfigInfo.cs
   trunk/mcs/class/System.Configuration/System.Configuration/SectionGroupInfo.cs
   trunk/mcs/class/System.Configuration/System.Configuration/SectionInfo.cs
Log:
proper handling of <configSections>

Modified: trunk/mcs/class/System.Configuration/System.Configuration/ChangeLog
===================================================================
--- trunk/mcs/class/System.Configuration/System.Configuration/ChangeLog 
2006-11-28 20:25:23 UTC (rev 68614)
+++ trunk/mcs/class/System.Configuration/System.Configuration/ChangeLog 
2006-11-28 20:26:56 UTC (rev 68615)
@@ -1,3 +1,12 @@
+2006-11-28  Marek Habersack  <[EMAIL PROTECTED]>
+
+       * SectionGroupInfo.cs: Implement merging of section groups with
+       the same names and parents.
+
+       * ConfigInfo.cs: Add an abstract method for merging sections.
+
+       * SectionInfo.cs: Add implementation of an abstract base method
+
 2006-08-23  Konstantin Triger <[EMAIL PROTECTED]>
 
        * SectionInfo.cs: refactoring - remove unneeded bool? usage.

Modified: 
trunk/mcs/class/System.Configuration/System.Configuration/ConfigInfo.cs
===================================================================
--- trunk/mcs/class/System.Configuration/System.Configuration/ConfigInfo.cs     
2006-11-28 20:25:23 UTC (rev 68614)
+++ trunk/mcs/class/System.Configuration/System.Configuration/ConfigInfo.cs     
2006-11-28 20:26:56 UTC (rev 68615)
@@ -80,6 +80,8 @@
                public abstract void WriteConfig (Configuration cfg, XmlWriter 
writer, ConfigurationSaveMode mode);
                public abstract void ReadData (Configuration config, 
XmlTextReader reader, bool overrideAllowed);
                public abstract void WriteData (Configuration config, XmlWriter 
writer, ConfigurationSaveMode mode);
+               
+               internal abstract void Merge (ConfigInfo data);
        }
 }
 

Modified: 
trunk/mcs/class/System.Configuration/System.Configuration/SectionGroupInfo.cs
===================================================================
--- 
trunk/mcs/class/System.Configuration/System.Configuration/SectionGroupInfo.cs   
    2006-11-28 20:25:23 UTC (rev 68614)
+++ 
trunk/mcs/class/System.Configuration/System.Configuration/SectionGroupInfo.cs   
    2006-11-28 20:26:56 UTC (rev 68615)
@@ -198,9 +198,9 @@
 
                                if (name == "section")
                                        cinfo = new SectionInfo ();
-                               else if (name == "sectionGroup")
+                               else if (name == "sectionGroup") {
                                        cinfo = new SectionGroupInfo ();
-                               else
+                               } else
                                        ThrowException ("Unrecognized element: 
" + reader.Name, reader);
                                        
                                cinfo.ReadConfig (cfg, streamName, reader);
@@ -210,6 +210,9 @@
                                if (actInfo != null) {
                                        if (actInfo.GetType () != cinfo.GetType 
())
                                                ThrowException ("A section or 
section group named '" + cinfo.Name + "' already exists", reader);
+                                       // Merge all the new data
+                                       actInfo.Merge (cinfo);
+                                       
                                        // Make sure that this section is saved 
in this configuration file:
                                        actInfo.StreamName = streamName;
                                }
@@ -340,9 +343,33 @@
                                if (data != null)
                                        return data;
                        }
+                       // It might be in the root section group
                        return null;
                }
 
+               internal override void Merge (ConfigInfo newData)
+               {
+                       SectionGroupInfo data = newData as SectionGroupInfo;
+                       if (data == null)
+                               return;
+                       ConfigInfo actInfo;
+                       if (data.sections != null && data.sections.Count > 0)
+                               foreach (string key in data.sections.AllKeys) {
+                                       actInfo = sections[key];
+                                       if (actInfo != null)
+                                               continue;
+                                       sections.Add (key, data.sections[key]);
+                               }
+                       
+                       if (data.groups != null && data.sections.Count > 0)
+                               foreach (string key in data.groups.AllKeys) {
+                                       actInfo = groups[key];
+                                       if (actInfo != null)
+                                               continue;
+                                       groups.Add (key, data.groups[key]);
+                               }
+               }
+               
                public void WriteRootData (XmlWriter writer, Configuration 
config, ConfigurationSaveMode mode)
                {
                        WriteContent (writer, config, mode, false);

Modified: 
trunk/mcs/class/System.Configuration/System.Configuration/SectionInfo.cs
===================================================================
--- trunk/mcs/class/System.Configuration/System.Configuration/SectionInfo.cs    
2006-11-28 20:25:23 UTC (rev 68614)
+++ trunk/mcs/class/System.Configuration/System.Configuration/SectionInfo.cs    
2006-11-28 20:26:56 UTC (rev 68615)
@@ -207,6 +207,9 @@
                                tr.Close ();*/
                        }
                }
+               
+               internal override void Merge (ConfigInfo data)
+               {}
        }
 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to