Explorar el Código

2003-05-01 Gonzalo Paniagua Javier <[email protected]>

	* System.Web.Compilation/AspGenerator.cs: also support data bind syntax
	inside tags not processed as controls. Added debugging method.

	* System.Web.Compilation/TemplateControlCompiler.cs: reset the number
	of data binding handlers in the proper place. Small fix when getting the
	container type.

	* System.Web.UI/ApplicationFileParser.cs: use the generator to actually
	parse the file.

	* System.Web.UI/ControlBuilder.cs: small fix in NamingContainerType
	because TemplateBuilders have a null ControlType. When a control is
	appended to a parent, assign the child's parent.

	* System.Web.UI/UserControlParser.cs: fixed the value of InputFile.

	IBuySpy works again!

svn path=/trunk/mcs/; revision=14170
Gonzalo Paniagua Javier hace 22 años
padre
commit
ce55913aed

+ 25 - 0
mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs

@@ -109,6 +109,10 @@ namespace System.Web.Compilation
 			if (text.Length > 0)
 				FlushText ();
 
+#if DEBUG
+			PrintTree (rootBuilder, 0);
+#endif
+
 			if (stack.Count > 1)
 				throw new ParseException (stack.Builder.location,
 						"Expecting </" + stack.Builder.TagName + ">" + stack.Builder);
@@ -118,6 +122,25 @@ namespace System.Web.Compilation
 			return compiler.GetCompiledType ();
 		}
 
+#if DEBUG
+		static void PrintTree (ControlBuilder builder, int indent)
+		{
+			if (builder == null)
+				return;
+
+			string i = new string ('\t', indent);
+			Console.Write (i);
+			Console.WriteLine ("b: {0} id: {1} type: {2} parent: {3}",
+					   builder, builder.ID, builder.ControlType, builder.parentBuilder);
+
+			if (builder.Children != null)
+			foreach (object o in builder.Children) {
+				if (o is ControlBuilder)
+					PrintTree ((ControlBuilder) o, indent++);
+			}
+		}
+#endif
+		
 		static void PrintLocation (ILocation loc)
 		{
 			Console.WriteLine ("\tFile name: " + loc.Filename);
@@ -331,6 +354,8 @@ namespace System.Web.Compilation
 					builder.AppendSubBuilder (new CodeRenderBuilder (tagid, false, location));
 				else if (tagtype == TagType.CodeRenderExpression)
 					builder.AppendSubBuilder (new CodeRenderBuilder (tagid, true, location));
+				else if (tagtype == TagType.DataBinding)
+					builder.AppendSubBuilder (new DataBindingBuilder (tagid, location));
 				else
 					builder.AppendLiteralString (location.PlainText);
 			}

+ 8 - 0
mcs/class/System.Web/System.Web.Compilation/ChangeLog

@@ -1,3 +1,11 @@
+2003-05-01  Gonzalo Paniagua Javier <[email protected]>
+
+	* AspGenerator.cs: also support data bind syntax inside tags not
+	processed as controls. Added debugging method.
+
+	* TemplateControlCompiler.cs: reset the number of data binding handlers 
+	in the proper place. Small fix when getting the container type.
+
 2003-04-30  Gonzalo Paniagua Javier <[email protected]>
 
 	* TemplateControlCompiler.cs: correctly set the TemplateSourceDirectory 

+ 1 - 3
mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs

@@ -262,7 +262,6 @@ namespace System.Web.Compilation
 		bool ProcessPropertiesAndFields (ControlBuilder builder, MemberInfo member, string id, string attValue)
 		{
 			CodeMemberMethod method = builder.method;
-			this.dataBoundAtts = 0;
 			int hyphen = id.IndexOf ('-');
 
 			bool isPropertyInfo = (member is PropertyInfo);
@@ -330,6 +329,7 @@ namespace System.Web.Compilation
 		
 		void CreateAssignStatementsFromAttributes (ControlBuilder builder)
 		{
+			this.dataBoundAtts = 0;
 			IDictionary atts = builder.attribs;
 			if (atts == null || atts.Count == 0)
 				return;
@@ -481,8 +481,6 @@ namespace System.Web.Compilation
 		static Type GetContainerType (ControlBuilder builder)
 		{
 			Type type = builder.NamingContainerType;
-			if (builder.ControlType != null && !typeof (ITemplate).IsAssignableFrom (builder.ControlType))
-				return type;
 
 			PropertyInfo prop = type.GetProperty ("Items", noCaseFlags);
 			if (prop == null)

+ 2 - 2
mcs/class/System.Web/System.Web.UI/ApplicationFileParser.cs

@@ -29,8 +29,8 @@ namespace System.Web.UI
 		internal static Type GetCompiledApplicationType (string inputFile, HttpContext context)
 		{
 			ApplicationFileParser parser = new ApplicationFileParser (inputFile, context);
-			parser.Context = context;
-			return parser.CompileIntoType ();
+			AspGenerator generator = new AspGenerator (parser);
+			return generator.GetCompiledType ();
 		}
 
 		protected override Type DefaultBaseType {

+ 11 - 0
mcs/class/System.Web/System.Web.UI/ChangeLog

@@ -1,3 +1,14 @@
+2003-05-01  Gonzalo Paniagua Javier <[email protected]>
+
+	* ApplicationFileParser.cs: use the generator to actually parse the
+	file.
+
+	* ControlBuilder.cs: small fix in NamingContainerType because
+	TemplateBuilders have a null ControlType. When a control is appended
+	to a parent, assign the child's parent.
+
+	* UserControlParser.cs: fixed the value of InputFile.
+
 2003-04-30  Gonzalo Paniagua Javier <[email protected]>
 
 	* ApplicationFileParser.cs: store the Context and override

+ 3 - 2
mcs/class/System.Web/System.Web.UI/ControlBuilder.cs

@@ -25,7 +25,7 @@ namespace System.Web.UI {
 							   BindingFlags.IgnoreCase;
 
 		TemplateParser parser;
-		ControlBuilder parentBuilder;
+		internal ControlBuilder parentBuilder;
 		Type type;	       
 		string tagName;
 		string id;
@@ -112,7 +112,7 @@ namespace System.Web.UI {
 
 				Type ptype = parentBuilder.ControlType;
 				if (ptype == null)
-					return typeof (Control);
+					return parentBuilder.NamingContainerType;
 
 				if (!typeof (INamingContainer).IsAssignableFrom (ptype))
 					return parentBuilder.NamingContainerType;
@@ -175,6 +175,7 @@ namespace System.Web.UI {
 		{
 			subBuilder.OnAppendToParentBuilder (this);
 			
+			subBuilder.parentBuilder = this;
 			if (childrenAsProperties) {
 				AppendToProperty (subBuilder);
 				return;

+ 2 - 1
mcs/class/System.Web/System.Web.UI/UserControlParser.cs

@@ -10,6 +10,7 @@ using System;
 using System.IO;
 using System.Web;
 using System.Web.Compilation;
+using System.Web.Util;
 
 namespace System.Web.UI
 {
@@ -18,7 +19,7 @@ namespace System.Web.UI
 		internal UserControlParser (string virtualPath, string inputFile, HttpContext context)
 		{
 			Context = context;
-			InputFile = Path.Combine (context.Request.MapPath (virtualPath), inputFile);
+			InputFile = context.Request.MapPath (UrlUtils.Combine (virtualPath, inputFile));
 		}
 		
 		public static Type GetCompiledType (string virtualPath, string inputFile, HttpContext context)