Просмотр исходного кода

2005-06-13 Lluis Sanchez Gual <[email protected]>

	* Directive.cs: Register the MasterType directive.
	* PageCompiler.cs: If a MasterType is specified, add a type specific
	Master property. All this fixes bug #75192.


svn path=/trunk/mcs/; revision=45885
Lluis Sanchez 20 лет назад
Родитель
Сommit
2fee37b32b

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

@@ -1,3 +1,9 @@
+2005-06-13  Lluis Sanchez Gual <[email protected]>
+
+	* Directive.cs: Register the MasterType directive.
+	* PageCompiler.cs: If a MasterType is specified, add a type specific
+	Master property. All this fixes bug #75192.
+
 2005-06-11 Gonzalo Paniagua Javier <[email protected]>
 
 	* TemplateControlCompiler.cs: when mapping an attribute name to a field

+ 8 - 0
mcs/class/System.Web/System.Web.Compilation/Directive.cs

@@ -66,6 +66,10 @@ namespace System.Web.Compilation
 
 		static string [] application_atts = { "description", "inherits", "codebehind" };
 
+#if NET_2_0
+		static string [] mastertype_atts = { "virtualpath", "typename" };
+#endif
+		
 		static Directive ()
 		{
 			InitHash ();
@@ -125,6 +129,10 @@ namespace System.Web.Compilation
 			directivesHash.Add ("APPLICATION", valid_attributes);
 
 #if NET_2_0
+			valid_attributes = new Hashtable (provider, comparer);
+			foreach (string att in mastertype_atts) valid_attributes.Add (att, null);
+			directivesHash.Add ("MASTERTYPE", valid_attributes);
+			
 			valid_attributes = new Hashtable (provider, comparer);
 			foreach (string att in control_atts) valid_attributes.Add (att, null);
 			directivesHash.Add ("MASTER", valid_attributes);

+ 13 - 0
mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs

@@ -194,6 +194,19 @@ namespace System.Web.Compilation
 		{
 			base.CreateMethods ();
 
+#if NET_2_0
+			if (pageParser.MasterType != null) {
+				CodeMemberProperty mprop = new CodeMemberProperty ();
+				mprop.Name = "Master";
+				mprop.Type = new CodeTypeReference (pageParser.MasterType);
+				mprop.Attributes = MemberAttributes.Public | MemberAttributes.New;
+				CodeExpression prop = new CodePropertyReferenceExpression (new CodeBaseReferenceExpression (), "Master");
+				prop = new CodeCastExpression (pageParser.MasterType, prop);
+				mprop.GetStatements.Add (new CodeMethodReturnStatement (prop));
+				mainClass.Members.Add (mprop);
+			}
+#endif
+			
 			CreateGetTypeHashCode ();
 		}