Merge branch 'master' of github.com:mono/mono
[mono.git] / mcs / class / System.Web / System.Web.UI / UserControlParser.cs
index 3a5e8af74b9331136864490da441779a35141efd..b93e19fb57a74edfa84275451e6cc3357057512b 100644 (file)
@@ -29,6 +29,7 @@
 //
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 using System.Web;
 using System.Web.Compilation;
@@ -38,51 +39,52 @@ namespace System.Web.UI
 {
        internal class UserControlParser : TemplateControlParser
        {
-#if NET_2_0
                string masterPage;
+#if NET_4_0
+               string providerName;
 #endif
-
-               internal UserControlParser (string virtualPath, string inputFile, HttpContext context)
+               internal UserControlParser (VirtualPath virtualPath, string inputFile, HttpContext context)
                        : this (virtualPath, inputFile, context, null)
                {
                }
 
-               internal UserControlParser (string virtualPath, string inputFile, ArrayList deps, HttpContext context)
+               internal UserControlParser (VirtualPath virtualPath, string inputFile, List <string> deps, HttpContext context)
                        : this (virtualPath, inputFile, context, null)
                {
                        this.Dependencies = deps;
                }
-               
-               internal UserControlParser (string virtualPath, string inputFile, HttpContext context, string type)
+
+               internal UserControlParser (VirtualPath virtualPath, string inputFile, HttpContext context, string type)
                {
+                       VirtualPath = virtualPath;
                        Context = context;
-                       BaseVirtualDir = UrlUtils.GetDirectory (virtualPath);
+                       BaseVirtualDir = virtualPath.DirectoryNoNormalize;
                        InputFile = inputFile;
                        SetBaseType (type);
                        AddApplicationAssembly ();
+                       LoadConfigDefaults ();
                }
 
-#if NET_2_0
-               internal UserControlParser (string virtualPath, TextReader reader, HttpContext context)
+               internal UserControlParser (VirtualPath virtualPath, TextReader reader, HttpContext context)
                        : this (virtualPath, null, reader, context)
                {
                }
                
-               internal UserControlParser (string virtualPath, string inputFile, TextReader reader, HttpContext context)
+               internal UserControlParser (VirtualPath virtualPath, string inputFile, TextReader reader, HttpContext context)
                {
+                       VirtualPath = virtualPath;
                        Context = context;
-                       BaseVirtualDir = UrlUtils.GetDirectory (virtualPath);
-
-                       if (String.IsNullOrEmpty (inputFile)) {
-                               HttpRequest req = context != null ? context.Request : null;
-                               if (req != null)
-                                       InputFile = req.MapPath (virtualPath);
-                       } else
+                       BaseVirtualDir = virtualPath.DirectoryNoNormalize;
+                       
+                       if (String.IsNullOrEmpty (inputFile))
+                               InputFile = virtualPath.PhysicalPath;
+                       else
                                InputFile = inputFile;
                        
                        Reader = reader;
                        SetBaseType (null);
                        AddApplicationAssembly ();
+                       LoadConfigDefaults ();
                }
 
                internal UserControlParser (TextReader reader, int? uniqueSuffix, HttpContext context)
@@ -90,7 +92,8 @@ namespace System.Web.UI
                        Context = context;
 
                        string fpath = context.Request.FilePath;
-                       BaseVirtualDir = UrlUtils.GetDirectory (fpath);
+                       VirtualPath = new VirtualPath (fpath);
+                       BaseVirtualDir = VirtualPathUtility.GetDirectory (fpath, false);
 
                        // We're probably being called by ParseControl - let's use the requested
                        // control's path plus unique suffix as our input file, since that's the
@@ -99,6 +102,7 @@ namespace System.Web.UI
                        Reader = reader;
                        SetBaseType (null);
                        AddApplicationAssembly ();
+                       LoadConfigDefaults ();
                }               
 
                internal static Type GetCompiledType (TextReader reader, int? inputHashCode, HttpContext context)
@@ -106,56 +110,68 @@ namespace System.Web.UI
                        UserControlParser ucp = new UserControlParser (reader, inputHashCode, context);
                        return ucp.CompileIntoType ();
                }
-#endif
                
-               internal static Type GetCompiledType (string virtualPath, string inputFile, ArrayList deps, HttpContext context)
+               internal static Type GetCompiledType (string virtualPath, string inputFile, List <string> deps, HttpContext context)
                {
-                       UserControlParser ucp = new UserControlParser (virtualPath, inputFile, deps, context);
+                       UserControlParser ucp = new UserControlParser (new VirtualPath (virtualPath), inputFile, deps, context);
+
                        return ucp.CompileIntoType ();
                }
 
                public static Type GetCompiledType (string virtualPath, string inputFile, HttpContext context)
                {
-                       UserControlParser ucp = new UserControlParser (virtualPath, inputFile, context);
+                       UserControlParser ucp = new UserControlParser (new VirtualPath (virtualPath), inputFile, context);
+
                        return ucp.CompileIntoType ();
                }
 
-               protected override Type CompileIntoType ()
+               internal override Type CompileIntoType ()
                {
                        AspGenerator generator = new AspGenerator (this);
                        return generator.GetCompiledType ();
                }
 
-               internal override void ProcessMainAttributes (Hashtable atts)
+               internal override void ProcessMainAttributes (IDictionary atts)
                {
-#if NET_2_0
                        masterPage = GetString (atts, "MasterPageFile", null);
                        if (masterPage != null)
                                AddDependency (masterPage);
-#endif
 
                        base.ProcessMainAttributes (atts);
                }
+#if NET_4_0
+               internal override void ProcessOutputCacheAttributes (IDictionary atts)
+               {
+                       providerName = GetString (atts, "ProviderName", null);
+                       base.ProcessOutputCacheAttributes (atts);
+               }
 
-#if NET_2_0
-               internal override string DefaultBaseTypeName {
-                       get { return PagesConfig.UserControlBaseType; }
+               internal override Type DefaultBaseType {
+                       get {
+                               Type ret = PageParser.DefaultUserControlBaseType;
+                               if (ret == null)
+                                       return base.DefaultBaseType;
+
+                               return ret;
+                       }
                }
-#else
+#endif
                internal override string DefaultBaseTypeName {
-                       get { return "System.Web.UI.UserControl"; }
+                       get { return PagesConfig.UserControlBaseType; }
                }
-#endif
+
                internal override string DefaultDirectiveName {
                        get { return "control"; }
                }
 
-#if NET_2_0
                internal string MasterPageFile {
                        get { return masterPage; }
                }
+#if NET_4_0
+               internal string ProviderName {
+                       get { return providerName; }
+               }
 #endif
-
        }
 }