Author: mhabersack
Date: 2006-11-27 19:17:26 -0500 (Mon, 27 Nov 2006)
New Revision: 68545

Modified:
   trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.cs
   trunk/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
   trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs
   trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog
   trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
   trunk/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs
   trunk/mcs/class/System.Web/System.Web.UI/TemplateParser.cs
Log:
Add support for centralized control registration (from web.config) as well as 
for the system.web/pages/namespaces collection

Modified: 
trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.cs   
2006-11-28 00:10:10 UTC (rev 68544)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.cs   
2006-11-28 00:17:26 UTC (rev 68545)
@@ -123,6 +123,7 @@
                        } else {
                                
WebConfigurationManager.ExtraAssemblies.Add(ret.PathToAssembly);
                                BuildManager.TopLevelAssemblies.Add 
(ret.CompiledAssembly);
+                               BuildManager.HaveResources = true;
                        }
                        
                        return ret;

Modified: trunk/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs   
2006-11-28 00:10:10 UTC (rev 68544)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs   
2006-11-28 00:17:26 UTC (rev 68545)
@@ -277,7 +277,9 @@
                        }
 
                        isApplication = tparser.DefaultDirectiveName == 
"application";
-
+#if NET_2_0
+                       tparser.RegisterConfigControls ();
+#endif
                        Parse ();
 
                        BaseCompiler compiler = GetCompilerFromType ();

Modified: trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs   
2006-11-28 00:10:10 UTC (rev 68544)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs   
2006-11-28 00:17:26 UTC (rev 68545)
@@ -46,6 +46,7 @@
        public sealed class BuildManager {
                private static List<string> AppCode_Assemblies = new 
List<string>();
                private static List<Assembly> TopLevel_Assemblies = new 
List<Assembly>();
+               private static bool haveResources;
                
                internal BuildManager ()
                {
@@ -201,18 +202,17 @@
 
                // Assemblies built from the App_Code directory
                public static IList CodeAssemblies {
-                       get {
-                               return AppCode_Assemblies;
-                       }
+                       get { return AppCode_Assemblies; }
                }
 
-               internal static IList TopLevelAssemblies 
-               {
-                       get {
-                               return TopLevel_Assemblies;
-                       }
+               internal static IList TopLevelAssemblies {
+                       get { return TopLevel_Assemblies; }
                }
-               
+
+               internal static bool HaveResources {
+                       get { return haveResources; }
+                       set { haveResources = value; }
+               }
        }
 }
 

Modified: trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2006-11-28 
00:10:10 UTC (rev 68544)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2006-11-28 
00:17:26 UTC (rev 68545)
@@ -1,3 +1,14 @@
+2006-11-28  Marek Habersack  <[EMAIL PROTECTED]>
+
+       * BuildManager.cs: Add an internal property to signal whether or
+       not we have any resources from App_{Global,Local}Resources
+
+       * AspGenerator.cs: Register controls from
+       system.web/pages/controls collection before parsing.
+
+       * AppResourcesCompiler.cs: Let the build process know if we have
+       compiled any resources from App_{Global,Local}Resources
+
 2006-11-27  Marek Habersack  <[EMAIL PROTECTED]>
 
        * CachingCompiler.cs: Automatically reference App_Code

Modified: trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/ChangeLog  2006-11-28 00:10:10 UTC 
(rev 68544)
+++ trunk/mcs/class/System.Web/System.Web.UI/ChangeLog  2006-11-28 00:17:26 UTC 
(rev 68545)
@@ -1,3 +1,16 @@
+2006-11-28  Marek Habersack  <[EMAIL PROTECTED]>
+
+       * TemplateControlParser.cs: Use the new TemplateParser methods to
+       register controls/namespaces
+
+       * TemplateParser.cs: Implement support for the
+       system.web/pages/namespaces collection instead of hard-coding the
+       namespaces into the source.
+       Refactoring: added two internal methods to handle both the
+       system.web/pages/controls registration and the Register directive.
+       Added a new internal method to pull the system.web/pages/controls
+       collection before parsing.
+
 2006-11-27  Marek Habersack  <[EMAIL PROTECTED]>
 
        * SimpleWebHandlerParser.cs: Added support for looking up types in

Modified: trunk/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs   
2006-11-28 00:10:10 UTC (rev 68544)
+++ trunk/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs   
2006-11-28 00:17:26 UTC (rev 68545)
@@ -56,7 +56,7 @@
                protected TemplateControlParser ()
                {
                }
-
+               
                internal override void ProcessMainAttributes (Hashtable atts)
                {
                        autoEventWireup = GetBool (atts, "AutoEventWireup", 
PagesConfig.AutoEventWireup);
@@ -102,10 +102,7 @@
                                        if (atts.Count != 0)
                                                ThrowParseException ("Unknown 
attribute: " + GetOneKey (atts));
 
-                                       AddImport (ns);
-                                       Assembly ass = AddAssemblyByName 
(assembly);
-                                       AddDependency (ass.Location);
-                                       RootBuilder.Foundry.RegisterFoundry 
(tagprefix, ass, ns);
+                                       RegisterNamespace (tagprefix, ns, 
assembly);
                                        return;
                                }
 
@@ -121,28 +118,7 @@
                                if (!src.EndsWith (".ascx"))
                                        ThrowParseException ("Source file 
extension for controls must be .ascx");
 
-                               string realpath = MapPath (src);
-                               if (!File.Exists (realpath))
-                                       throw new ParseException (Location, 
"Could not find file \"" 
-                                               + realpath + "\".");
-
-                               string vpath = UrlUtils.Combine 
(BaseVirtualDir, src);
-                               Type type = null;
-                               AddDependency (realpath);
-                               try {
-                                       ArrayList other_deps = new ArrayList ();
-                                       type = 
UserControlParser.GetCompiledType (vpath, realpath, other_deps, Context);
-                                       foreach (string s in other_deps) {
-                                               AddDependency (s);
-                                       }
-                               } catch (ParseException pe) {
-                                       if (this is UserControlParser)
-                                               throw new ParseException 
(Location, pe.Message, pe);
-                                       throw;
-                               }
-
-                               AddAssembly (type.Assembly, true);
-                               RootBuilder.Foundry.RegisterFoundry (tagprefix, 
tagname, type);
+                               RegisterCustomControl (tagprefix, tagname, src);
                                return;
                        }
 

Modified: trunk/mcs/class/System.Web/System.Web.UI/TemplateParser.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/TemplateParser.cs  2006-11-28 
00:10:10 UTC (rev 68544)
+++ trunk/mcs/class/System.Web/System.Web.UI/TemplateParser.cs  2006-11-28 
00:17:26 UTC (rev 68545)
@@ -30,6 +30,7 @@
 
 using System.CodeDom.Compiler;
 using System.Collections;
+using System.Globalization;
 using System.IO;
 using System.Reflection;
 using System.Security.Permissions;
@@ -67,6 +68,7 @@
                string oc_header, oc_custom, oc_param, oc_controls;
                bool oc_shared;
                OutputCacheLocation oc_location;
+               CultureInfo invariantCulture = CultureInfo.InvariantCulture;
 #if NET_2_0
                string src;
                string partialClassName;
@@ -77,6 +79,9 @@
                internal TemplateParser ()
                {
                        imports = new ArrayList ();
+#if NET_2_0
+                       AddNamespaces (imports);
+#else
                        imports.Add ("System");
                        imports.Add ("System.Collections");
                        imports.Add ("System.Collections.Specialized");
@@ -85,12 +90,12 @@
                        imports.Add ("System.Text.RegularExpressions");
                        imports.Add ("System.Web");
                        imports.Add ("System.Web.Caching");
-                       imports.Add ("System.Resources"); // should perhaps be 
conditional on App_Global/LocalResources existence?
                        imports.Add ("System.Web.Security");
                        imports.Add ("System.Web.SessionState");
                        imports.Add ("System.Web.UI");
                        imports.Add ("System.Web.UI.WebControls");
                        imports.Add ("System.Web.UI.HtmlControls");
+#endif
 
                        assemblies = new ArrayList ();
 #if NET_2_0
@@ -116,7 +121,7 @@
 
                        language = CompilationConfig.DefaultLanguage;
                }
-
+               
                internal void AddApplicationAssembly ()
                {
                        string location = 
Context.ApplicationInstance.AssemblyLocation;
@@ -127,6 +132,78 @@
 
                protected abstract Type CompileIntoType ();
 
+#if NET_2_0
+               void AddNamespaces (ArrayList imports)
+               {
+                       if (BuildManager.HaveResources)
+                               imports.Add ("System.Resources");
+                       
+                       PagesSection pages = WebConfigurationManager.GetSection 
("system.web/pages") as PagesSection;
+                       if (pages == null)
+                               return;
+
+                       NamespaceCollection namespaces = pages.Namespaces;
+                       if (namespaces == null || namespaces.Count == 0)
+                               return;
+
+                       foreach (NamespaceInfo nsi in namespaces)
+                               imports.Add (nsi.Namespace);
+               }
+               
+               internal void RegisterConfigControls ()
+               {
+                       PagesSection pages = WebConfigurationManager.GetSection 
("system.web/pages") as PagesSection;
+                       if (pages == null)
+                               return;
+
+                       TagPrefixCollection controls = pages.Controls;
+                       if (controls == null || controls.Count == 0)
+                               return;
+
+                       foreach (TagPrefixInfo tpi in controls) {
+                               if (!String.IsNullOrEmpty (tpi.TagName))
+                                       RegisterCustomControl (tpi.TagPrefix, 
tpi.TagName, tpi.Source);
+                               else if (!String.IsNullOrEmpty (tpi.Namespace))
+                                       RegisterNamespace (tpi.TagPrefix, 
tpi.Namespace, tpi.Assembly);
+                       }
+               }
+#endif
+               
+               internal void RegisterCustomControl (string tagPrefix, string 
tagName, string src)
+               {
+                       string realpath = MapPath (src);
+                       if (String.Compare (realpath, inputFile, false, 
invariantCulture) == 0)
+                               return;
+                       
+                       if (!File.Exists (realpath))
+                               throw new ParseException (Location, "Could not 
find file \"" + realpath + "\".");
+                       string vpath = UrlUtils.Combine (BaseVirtualDir, src);
+                       Type type = null;
+                       AddDependency (realpath);
+                       try {
+                               ArrayList other_deps = new ArrayList ();
+                               type = UserControlParser.GetCompiledType 
(vpath, realpath, other_deps, Context);
+                               foreach (string s in other_deps) {
+                                       AddDependency (s);
+                               }
+                       } catch (ParseException pe) {
+                               if (this is UserControlParser)
+                                       throw new ParseException (Location, 
pe.Message, pe);
+                               throw;
+                       }
+
+                       AddAssembly (type.Assembly, true);
+                       RootBuilder.Foundry.RegisterFoundry (tagPrefix, 
tagName, type);
+               }
+
+               internal void RegisterNamespace (string tagPrefix, string ns, 
string assembly)
+               {
+                       AddImport (ns);
+                       Assembly ass = AddAssemblyByName (assembly);
+                       AddDependency (ass.Location);
+                       RootBuilder.Foundry.RegisterFoundry (tagPrefix, ass, 
ns);
+               }
+               
                internal virtual void HandleOptions (object obj)
                {
                }

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

Reply via email to