[asp.net] Use faster string comparison in caches in System.Web.Compilation
[mono.git] / mcs / class / System.Web / System.Web.Compilation / AppCodeCompiler.cs
index 4820ba47412ef6a76b4bebf68124ddcd3421385b..3a288b642704fe4d0058be7acd5f7d119e0241de 100644 (file)
@@ -27,7 +27,7 @@
 // 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.CodeDom;
 using System.CodeDom.Compiler;
@@ -198,7 +198,7 @@ namespace System.Web.Compilation
                        }
 
                        CodeDomProvider provider = null;
-                       CompilationSection compilationSection = WebConfigurationManager.GetSection ("system.web/compilation") as CompilationSection;
+                       CompilationSection compilationSection = WebConfigurationManager.GetWebApplicationSection ("system.web/compilation") as CompilationSection;
                        if (compilerInfo == null) {
                                if (!CodeDomProvider.IsDefinedLanguage (compilationSection.DefaultLanguage))
                                        throw new HttpException ("Failed to retrieve default source language");
@@ -281,7 +281,7 @@ namespace System.Web.Compilation
                        if (file == null || file.Length == 0 || buildProviders == null || buildProviders.Count == 0)
                                return null;
 
-                       BuildProvider ret = buildProviders.GetProviderForExtension (Path.GetExtension (file));
+                       BuildProvider ret = buildProviders.GetProviderInstanceForExtension (Path.GetExtension (file));
                        if (ret != null && IsCorrectBuilderType (ret)) {
                                ret.SetVirtualPath (PhysicalToVirtual (file));
                                return ret;
@@ -359,7 +359,7 @@ namespace System.Web.Compilation
                bool ProcessAppCodeDir (string appCode, AppCodeAssembly defasm)
                {
                        // First process the codeSubDirectories
-                       CompilationSection cs = (CompilationSection) WebConfigurationManager.GetSection ("system.web/compilation");
+                       CompilationSection cs = (CompilationSection) WebConfigurationManager.GetWebApplicationSection ("system.web/compilation");
                        
                        if (cs != null) {
                                string aname;
@@ -614,7 +614,11 @@ namespace System.Web.Compilation
                {
                        if (ps == null || !ps.Enabled)
                                return false;
-                       if (!String.IsNullOrEmpty (ps.Inherits) || (ps.PropertySettings != null && ps.PropertySettings.Count > 0))
+
+                       RootProfilePropertySettingsCollection props = ps.PropertySettings;
+                       ProfileGroupSettingsCollection groups = props != null ? props.GroupSettings : null;
+                       
+                       if (!String.IsNullOrEmpty (ps.Inherits) || (props != null && props.Count > 0) || (groups != null && groups.Count > 0))
                                return true;
 
                        return false;
@@ -626,7 +630,7 @@ namespace System.Web.Compilation
                                return;
                        
                        string appCode = Path.Combine (HttpRuntime.AppDomainAppPath, "App_Code");
-                       ProfileSection ps = WebConfigurationManager.GetSection ("system.web/profile") as ProfileSection;
+                       ProfileSection ps = WebConfigurationManager.GetWebApplicationSection ("system.web/profile") as ProfileSection;
                        bool haveAppCodeDir = Directory.Exists (appCode);
                        bool haveCustomProfile = HaveCustomProfile (ps);
                        
@@ -668,9 +672,17 @@ namespace System.Web.Compilation
                                } else
                                        return;
 
-                               if (HttpApplication.LoadTypeFromBin (providerTypeName) == null)
-                                       throw new HttpException (String.Format ("Profile provider type not found: {0}",
-                                                                               providerTypeName));
+                               Exception noTypeException = null;
+                               Type ptype = null;
+                               
+                               try {
+                                       ptype = HttpApplication.LoadTypeFromBin (providerTypeName);
+                               } catch (Exception ex) {
+                                       noTypeException = ex;
+                               }
+
+                               if (ptype == null)
+                                       throw new HttpException (String.Format ("Profile provider type not found: {0}", providerTypeName), noTypeException);
                        }
                }
 
@@ -734,4 +746,4 @@ namespace System.Web.Compilation
                }
        }
 }
-#endif
+