* WebConfigurationManager.cs: fixed GetSection to execute GetRuntimeObject, refactore...
authorVladimir Krasnov <krasnov@mono-cvs.ximian.com>
Mon, 18 Dec 2006 15:59:16 +0000 (15:59 -0000)
committerVladimir Krasnov <krasnov@mono-cvs.ximian.com>
Mon, 18 Dec 2006 15:59:16 +0000 (15:59 -0000)
svn path=/trunk/mcs/; revision=69664

mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog
mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs

index 215c2d7532c300337e5c5cf44e0db67d8a724784..369424bbc30e03f2359189a38dbf7cba09400f42 100644 (file)
@@ -1,3 +1,8 @@
+2006-12-18  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * WebConfigurationManager.cs: fixed GetSection to execute
+       GetRuntimeObject, refactored GetSection and GetWebApplicationSection
+
 2006-12-17  Vladimir Krasnov  <vladimirk@mainsoft.com>
 
        * HttpHandlerAction.cs: fixed 'verb' config property
index c6b1f137b599d74a1ece3291db0e54f5905b029b..80cc91f9793e1a554da8c3a0881dd39430af50e0 100644 (file)
@@ -243,60 +243,35 @@ namespace System.Web.Configuration {
 
                public static object GetSection (string sectionName)
                {
-                       _Configuration c;
-                       if (HttpContext.Current != null
-                           && HttpContext.Current.Request != null)
-                               c = OpenWebConfiguration (HttpContext.Current.Request.Path);
-                       else
-                               c = OpenWebConfiguration (HttpRuntime.AppDomainAppVirtualPath);
+                       string path = (HttpContext.Current != null
+                           && HttpContext.Current.Request != null) ?
+                               HttpContext.Current.Request.Path : HttpRuntime.AppDomainAppVirtualPath;
 
-                       if (c == null)
-                               return null;
-                       else
-                               return c.GetSection (sectionName);
+                       return GetSection (sectionName, path);
                }
 
                public static object GetSection (string sectionName, string path)
                {
-                       try {
-                               _Configuration c = OpenWebConfiguration (path);
-                               return c.GetSection (sectionName);
-                       }
-                       catch {
-                               return null;
-                       }
-               }
-
-               static _Configuration GetWebApplicationConfiguration ()
-               {
-                       _Configuration config;
+                       _Configuration c = OpenWebConfiguration (path);
+                       ConfigurationSection section = c.GetSection (sectionName);
 
-                       if (HttpContext.Current == null
-                           || HttpContext.Current.Request == null
-                           || HttpContext.Current.Request.ApplicationPath == null
-                           || HttpContext.Current.Request.ApplicationPath == "") {
-                               config = OpenWebConfiguration ("");
-                       }
-                       else {
-                               config = OpenWebConfiguration (HttpContext.Current.Request.ApplicationPath);
-                       }
+                       if (section == null)
+                               return null;
 
-                       return config;
+                       return get_runtime_object.Invoke (section, new object [0]);
                }
 
-               static MethodInfo get_runtime_object = typeof (ConfigurationSection).GetMethod ("GetRuntimeObject", BindingFlags.NonPublic | BindingFlags.Instance);
+               readonly static MethodInfo get_runtime_object = typeof (ConfigurationSection).GetMethod ("GetRuntimeObject", BindingFlags.NonPublic | BindingFlags.Instance);
 
                public static object GetWebApplicationSection (string sectionName)
                {
-                       _Configuration config = GetWebApplicationConfiguration ();
-                       if (config == null)
-                               return null;
+                       string path = (HttpContext.Current == null
+                               || HttpContext.Current.Request == null
+                               || HttpContext.Current.Request.ApplicationPath == null
+                               || HttpContext.Current.Request.ApplicationPath == "") ?
+                               String.Empty : HttpContext.Current.Request.ApplicationPath;
 
-                       ConfigurationSection section = config.GetSection (sectionName);
-                       if (section == null)
-                               return null;
-                       
-                       return get_runtime_object.Invoke (section, new object [0]);
+                       return GetSection (sectionName, path);
                }
 
                public static NameValueCollection AppSettings {