Author: atsushi
Date: 2007-06-13 12:14:09 -0400 (Wed, 13 Jun 2007)
New Revision: 79445

Added:
   
trunk/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationSectionGroupTest.cs
Modified:
   trunk/mcs/class/System.Configuration/ChangeLog
   trunk/mcs/class/System.Configuration/System.Configuration/ChangeLog
   trunk/mcs/class/System.Configuration/System.Configuration/Configuration.cs
   
trunk/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionGroup.cs
   trunk/mcs/class/System.Configuration/System.Configuration_test.dll.sources
   trunk/mcs/class/System.Configuration/Test/System.Configuration/ChangeLog
Log:
2007-06-13  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * ConfigurationSectionGroup.cs
          Configuration.cs : ConfigurationSectionGroup must be initialized
          at least when being added to a collection.

        * ConfigurationSectionGroupTest.cs : new (my change is with tests.)

        * System.Configuration_test.dll.sources :
          added ConfigurationSectionGroupTest.cs.



Modified: trunk/mcs/class/System.Configuration/ChangeLog
===================================================================
--- trunk/mcs/class/System.Configuration/ChangeLog      2007-06-13 15:59:00 UTC 
(rev 79444)
+++ trunk/mcs/class/System.Configuration/ChangeLog      2007-06-13 16:14:09 UTC 
(rev 79445)
@@ -1,3 +1,8 @@
+2007-06-13  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * System.Configuration_test.dll.sources :
+         added ConfigurationSectionGroupTest.cs.
+
 2007-03-19  Vladimir Krasnov  <[EMAIL PROTECTED]>
 
        * System.Configuration.dll.sources, System.Configuration20.vmwcsproj: 

Modified: trunk/mcs/class/System.Configuration/System.Configuration/ChangeLog
===================================================================
--- trunk/mcs/class/System.Configuration/System.Configuration/ChangeLog 
2007-06-13 15:59:00 UTC (rev 79444)
+++ trunk/mcs/class/System.Configuration/System.Configuration/ChangeLog 
2007-06-13 16:14:09 UTC (rev 79445)
@@ -1,3 +1,9 @@
+2007-06-13  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * ConfigurationSectionGroup.cs
+         Configuration.cs : ConfigurationSectionGroup must be initialized
+         at least when being added to a collection.
+
 2007-06-12  Vladimir Krasnov  <[EMAIL PROTECTED]>
 
        * ConfigurationElement.cs: refactored GetKeyProperties and

Modified: 
trunk/mcs/class/System.Configuration/System.Configuration/Configuration.cs
===================================================================
--- trunk/mcs/class/System.Configuration/System.Configuration/Configuration.cs  
2007-06-13 15:59:00 UTC (rev 79444)
+++ trunk/mcs/class/System.Configuration/System.Configuration/Configuration.cs  
2007-06-13 16:14:09 UTC (rev 79445)
@@ -340,6 +340,8 @@
                        section.ConfigHost = system.Host;
                        parentGroup.AddChild (section);
                        elementData [section] = sec;
+
+                       sec.Initialize (this, section);
                }
                
                internal void RemoveConfigInfo (ConfigInfo config)

Modified: 
trunk/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionGroup.cs
===================================================================
--- 
trunk/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionGroup.cs
      2007-06-13 15:59:00 UTC (rev 79444)
+++ 
trunk/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionGroup.cs
      2007-06-13 16:14:09 UTC (rev 79445)
@@ -34,7 +34,7 @@
 {
        public class ConfigurationSectionGroup
        {
-               bool require_declaration;
+               bool require_declaration, declared;
                string name, type_name;
 
                ConfigurationSectionCollection sections;
@@ -45,9 +45,22 @@
                public ConfigurationSectionGroup ()
                {
                }
-               
+
+               Configuration Config {
+                       get {
+                               if (config == null)
+                                       throw new InvalidOperationException 
("ConfigurationSectionGroup cannot be edited until it is added to a 
Configuration instance as its descendant");
+                               return config;
+                       }
+               }
+
+               bool initialized;
+
                internal void Initialize (Configuration config, 
SectionGroupInfo group)
                {
+                       if (initialized)
+                               throw new SystemException ("INTERNAL ERROR: 
this configuration section is being initialized twice: " + GetType ());
+                       initialized = true;
                        this.config = config;
                        this.group = group;
                }
@@ -68,9 +81,8 @@
                        ForceDeclaration (true);
                }
                
-               [MonoTODO]
                public bool IsDeclared {
-                       get { throw new NotImplementedException (); }
+                       get { return declared; }
                }
 
                [MonoTODO]
@@ -89,14 +101,14 @@
 
                public ConfigurationSectionGroupCollection SectionGroups {
                        get {
-                               if (groups == null) groups = new 
ConfigurationSectionGroupCollection (config, group);
+                               if (groups == null) groups = new 
ConfigurationSectionGroupCollection (Config, group);
                                return groups;
                        }
                }
 
                public ConfigurationSectionCollection Sections {
                        get {
-                               if (sections == null) sections = new 
ConfigurationSectionCollection (config, group);
+                               if (sections == null) sections = new 
ConfigurationSectionCollection (Config, group);
                                return sections;
                        }
                }

Modified: 
trunk/mcs/class/System.Configuration/System.Configuration_test.dll.sources
===================================================================
--- trunk/mcs/class/System.Configuration/System.Configuration_test.dll.sources  
2007-06-13 15:59:00 UTC (rev 79444)
+++ trunk/mcs/class/System.Configuration/System.Configuration_test.dll.sources  
2007-06-13 16:14:09 UTC (rev 79445)
@@ -6,6 +6,7 @@
 System.Configuration/ConfigurationPermissionTest.cs
 System.Configuration/ConfigurationPropertyTest.cs
 System.Configuration/ConfigurationManagerTest.cs
+System.Configuration/ConfigurationSectionGroupTest.cs
 System.Configuration/ConnectionStringSettingsTest.cs
 System.Configuration/DefaultValidatorTest.cs
 System.Configuration/ExeConfigurationFileMapTest.cs

Modified: 
trunk/mcs/class/System.Configuration/Test/System.Configuration/ChangeLog
===================================================================
--- trunk/mcs/class/System.Configuration/Test/System.Configuration/ChangeLog    
2007-06-13 15:59:00 UTC (rev 79444)
+++ trunk/mcs/class/System.Configuration/Test/System.Configuration/ChangeLog    
2007-06-13 16:14:09 UTC (rev 79445)
@@ -1,3 +1,7 @@
+2007-06-13  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * ConfigurationSectionGroupTest.cs : new (my change is with tests.)
+
 2007-04-17  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * ConfigurationManagerTest.cs : added SectionCollectionEnumerator().

Added: 
trunk/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationSectionGroupTest.cs
===================================================================
--- 
trunk/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationSectionGroupTest.cs
     2007-06-13 15:59:00 UTC (rev 79444)
+++ 
trunk/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationSectionGroupTest.cs
     2007-06-13 16:14:09 UTC (rev 79445)
@@ -0,0 +1,63 @@
+//
+// ConfigurationSectionGroupTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Configuration;
+using NUnit.Framework;
+
+using Config = System.Configuration.Configuration;
+
+namespace MonoTests.System.Configuration
+{
+       [TestFixture]
+       public class ConfigurationSectionGroupTest
+       {
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void EditBeforeAdd ()
+               {
+                       UserSettingsGroup u = new UserSettingsGroup ();
+                       ClientSettingsSection c = new ClientSettingsSection ();
+                       u.Sections.Add ("mine", c);
+               }
+
+               [Test]
+               public void EditAfterAdd ()
+               {
+                       Config cfg = ConfigurationManager.OpenExeConfiguration 
(ConfigurationUserLevel.None);
+                       UserSettingsGroup u = new UserSettingsGroup ();
+                       cfg.SectionGroups.Add ("userSettings", u);
+                       ClientSettingsSection c = new ClientSettingsSection ();
+                       u.Sections.Add ("mine", c);
+               }
+       }
+}
+
+#endif

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

Reply via email to