2009-01-30 Miguel de Icaza <miguel@novell.com>
[mono.git] / mcs / class / System.Web / System.Web.UI / RootBuilder.cs
index b5fd74e5d05d422eafde50b4ded1e94d576c79bb..15a87ea63815beb1d330bb1ea0c88513ff109e94 100644 (file)
@@ -39,7 +39,7 @@ namespace System.Web.UI {
        [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        public class RootBuilder : TemplateBuilder {
 
-               private Hashtable built_objects;
+               Hashtable built_objects;
 
                public RootBuilder ()
                {
@@ -110,9 +110,9 @@ namespace System.Web.UI {
                public RootBuilder (TemplateParser parser)
                {
                        foundry = new AspComponentFoundry ();
-                       line = 1;
+                       Line = 1;
                        if (parser != null)
-                               fileName = parser.InputFile;
+                               FileName = parser.InputFile;
                        Init (parser, null, null, null, null, null);
                }
 
@@ -121,28 +121,28 @@ namespace System.Web.UI {
                        if (tagName == null)
                                throw new ArgumentNullException ("tagName");
 
-                       string prefix;
-                       string cname;
-                       int colon = tagName.IndexOf (':');
-                       if (colon != -1) {
-                               if (colon == 0)
-                                       throw new Exception ("Empty TagPrefix is not valid");
-
-                               if (colon + 1 == tagName.Length)
-                                       return null;
-
-                               prefix = tagName.Substring (0, colon);
-                               cname = tagName.Substring (colon + 1);
-                       } else {
-                               prefix = "";
-                               cname = tagName;
-                       }
-
-                       Type t = foundry.GetComponentType (prefix, cname);
-                       if (t != null)
-                               return t;
-                       else if (prefix != "")
-                               throw new Exception ("TagPrefix " + prefix + " not registered");
+                       AspComponent component = foundry.GetComponent (tagName);
+                       
+                       if (component != null) {
+#if NET_2_0
+                               if (!String.IsNullOrEmpty (component.Source)) {
+                                       TemplateParser parser = Parser;
+
+                                       if (component.FromConfig) {
+                                               string parserDir = parser.BaseVirtualDir;
+                                               VirtualPath vp = new VirtualPath (component.Source);
+
+                                               if (parserDir == vp.Directory)
+                                                       throw new ParseException (parser.Location,
+                                                                                 String.Format ("The page '{0}' cannot use the user control '{1}', because it is registered in web.config and lives in the same directory as the page.", parser.VirtualPath, vp.Absolute));
+                                               
+                                               Parser.AddDependency (component.Source);
+                                       }
+                               }
+#endif
+                               return component.Type;
+                       } else if (component != null && component.Prefix != String.Empty)
+                               throw new Exception ("Unknown server tag '" + tagName + "'");
                        
                        return LookupHtmlControls (tagName, attribs);
                }
@@ -173,6 +173,10 @@ namespace System.Web.UI {
 
                internal AspComponentFoundry Foundry {
                        get { return foundry; }
+                       set {
+                               if (value is AspComponentFoundry)
+                                       foundry = value;
+                       }
                }
 #if NET_2_0
                // FIXME: it's empty (but not null) when using the new default ctor