Author: mhabersack
Date: 2007-03-21 16:14:03 -0500 (Wed, 21 Mar 2007)
New Revision: 74764

Modified:
   trunk/mcs/class/System.Web/System.Web.Compilation/BaseCompiler.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/TemplateParser.cs
Log:
2007-03-21  Marek Habersack  <[EMAIL PROTECTED]>
        * TemplateParser.cs: Added support for the CodeFileBaseClass directive. 
Fixes bug #81132

2007-03-21  Marek Habersack  <[EMAIL PROTECTED]>

        * BaseCompiler.cs: cast 'this' to CodeFileBaseClass in
        AssignAppRelativeVirtualPath if the attribute was defined.


Modified: trunk/mcs/class/System.Web/System.Web.Compilation/BaseCompiler.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/BaseCompiler.cs   
2007-03-21 20:33:39 UTC (rev 74763)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/BaseCompiler.cs   
2007-03-21 21:14:03 UTC (rev 74764)
@@ -192,8 +192,11 @@
 #if NET_2_0
                void AssignAppRelativeVirtualPath (CodeConstructor ctor)
                {
-                       Type baseType = parser.BaseType;
+                       Type baseType = parser.CodeFileBaseClassType;
+
                        if (baseType == null)
+                               baseType = parser.BaseType;
+                       if (baseType == null)
                                return;
                        if (!baseType.IsSubclassOf (typeof 
(System.Web.UI.TemplateControl)))
                                return;

Modified: trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2007-03-21 
20:33:39 UTC (rev 74763)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2007-03-21 
21:14:03 UTC (rev 74764)
@@ -1,5 +1,8 @@
 2007-03-21  Marek Habersack  <[EMAIL PROTECTED]>
 
+       * BaseCompiler.cs: cast 'this' to CodeFileBaseClass in
+       AssignAppRelativeVirtualPath if the attribute was defined.
+
        * TemplateControlCompiler.cs: added support for setting custom
        attributes of a base class from the Page or Control directive
        attributes.

Modified: trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/ChangeLog  2007-03-21 20:33:39 UTC 
(rev 74763)
+++ trunk/mcs/class/System.Web/System.Web.UI/ChangeLog  2007-03-21 21:14:03 UTC 
(rev 74764)
@@ -8,6 +8,7 @@
 
        * TemplateParser.cs: add support for custom attributes for the
        Page and Control directives.
+       Added support for the CodeFileBaseClass directive. Fixes bug #81132
 
 2007-03-20 Igor Zelmanovich <[EMAIL PROTECTED]>
 

Modified: trunk/mcs/class/System.Web/System.Web.UI/TemplateParser.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/TemplateParser.cs  2007-03-21 
20:33:39 UTC (rev 74763)
+++ trunk/mcs/class/System.Web/System.Web.UI/TemplateParser.cs  2007-03-21 
21:14:03 UTC (rev 74764)
@@ -79,6 +79,8 @@
 #if NET_2_0
                string src;
                string partialClassName;
+               string codeFileBaseClass;
+               Type codeFileBaseClassType;
                List <UnknownAttributeDescriptor> unknownMainAttributes;
 #endif
                Assembly srcAssembly;
@@ -545,7 +547,11 @@
                        // means that the code file has to be confirmed, but not
                        // used at this point.
                        src = GetString (atts, "CodeFile", null);
+                       codeFileBaseClass = GetString (atts, 
"CodeFileBaseClass", null);
 
+                       if (src == null && codeFileBaseClass != null)
+                               ThrowParseException ("The 'CodeFileBaseClass' 
attribute cannot be used without a 'CodeFile' attribute");
+                       
                        if (src != null && inherits != null) {
                                // Make sure the source exists
                                src = UrlUtils.Combine (BaseVirtualDir, src);
@@ -563,6 +569,16 @@
                                // Add the code file as an option to the
                                // compiler. This lets both files be compiled 
at once.
                                compilerOptions += " \"" + realPath + "\"";
+
+                               if (codeFileBaseClass != null) {
+                                       try {
+                                               codeFileBaseClassType = 
LoadType (codeFileBaseClass);
+                                       } catch (Exception) {
+                                       }
+
+                                       if (codeFileBaseClassType == null)
+                                               ThrowParseException ("Could not 
load type '{0}'", codeFileBaseClass);
+                               }
                        } else if (inherits != null) {
                                // We just set the inherits directly because 
this is a
                                // Single-Page model.
@@ -608,12 +624,16 @@
                        MemberInfo mi = null;
                        bool missing = false;
                        string memberName = name.Trim ().ToLower 
(CultureInfo.InvariantCulture);
+                       Type parent = codeFileBaseClassType;
+
+                       if (parent == null)
+                               parent = baseType;
                        
                        try {
-                               MemberInfo[] infos = baseType.GetMember 
(memberName,
-                                                                        
MemberTypes.Field | MemberTypes.Property,
-                                                                        
BindingFlags.Public | BindingFlags.Instance |
-                                                                        
BindingFlags.IgnoreCase | BindingFlags.Static);
+                               MemberInfo[] infos = parent.GetMember 
(memberName,
+                                                                      
MemberTypes.Field | MemberTypes.Property,
+                                                                      
BindingFlags.Public | BindingFlags.Instance |
+                                                                      
BindingFlags.IgnoreCase | BindingFlags.Static);
                                if (infos.Length != 0) {
                                        // prefer public properties to public 
methods (it's what MS.NET does)
                                        foreach (MemberInfo tmp in infos) {
@@ -735,6 +755,16 @@
                        get { return partialClassName; }
                }
 
+               internal string CodeFileBaseClass
+               {
+                       get { return codeFileBaseClass; }
+               }
+
+               internal Type CodeFileBaseClassType
+               {
+                       get { return codeFileBaseClassType; }
+               }
+               
                internal List <UnknownAttributeDescriptor> UnknownMainAttributes
                {
                        get { return unknownMainAttributes; }

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

Reply via email to