Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
2005-06-13 Lluis Sanchez Gual <lluis@novell.com>
	* PageParser.cs: Added MasterType property. Get the type from the
	MasterType directive.
	* MasterPageParser.cs: Added GetCompiledMasterType method.


svn path=/trunk/mcs/; revision=45884
  • Loading branch information
slluis committed Jun 13, 2005
1 parent 563425b commit f3846ab
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mcs/class/System.Web/System.Web.UI/ChangeLog
@@ -1,3 +1,9 @@
2005-06-13 Lluis Sanchez Gual <lluis@novell.com>

* PageParser.cs: Added MasterType property. Get the type from the
MasterType directive.
* MasterPageParser.cs: Added GetCompiledMasterType method.

2005-06-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>

* UserControl.cs:
Expand Down
6 changes: 6 additions & 0 deletions mcs/class/System.Web/System.Web.UI/MasterPageParser.cs
Expand Up @@ -52,6 +52,12 @@ public static MasterPage GetCompiledMasterInstance (string virtualPath, string i
return (MasterPage) mpp.GetCompiledInstance ();
}

public static Type GetCompiledMasterType (string virtualPath, string inputFile, HttpContext context)
{
MasterPageParser mpp = new MasterPageParser (virtualPath, inputFile, context);
return mpp.CompileIntoType ();
}

internal override Type DefaultBaseType {
get { return typeof (MasterPage); }
}
Expand Down
31 changes: 31 additions & 0 deletions mcs/class/System.Web/System.Web.UI/PageParser.cs
Expand Up @@ -60,6 +60,7 @@ public sealed class PageParser : TemplateControlParser

#if NET_2_0
string masterPage;
Type masterType;
#endif

public PageParser ()
Expand Down Expand Up @@ -243,6 +244,9 @@ internal override void ProcessMainAttributes (Hashtable atts)

#if NET_2_0
masterPage = GetString (atts, "MasterPageFile", null);

// Make sure the page exists
MasterPageParser.GetCompiledMasterType (masterPage, HttpContext.Current.Request.MapPath (masterPage), HttpContext.Current);
#endif
// Ignored by now
GetString (atts, "EnableViewStateMac", null);
Expand All @@ -251,6 +255,29 @@ internal override void ProcessMainAttributes (Hashtable atts)
base.ProcessMainAttributes (atts);
}

#if NET_2_0
internal override void AddDirective (string directive, Hashtable atts)
{
if (String.Compare ("MasterType", directive, true) == 0) {
string type = GetString (atts, "TypeName", null);
if (type != null) {
masterType = LoadType (type);
if (masterType == null)
ThrowParseException ("Could not load type '" + type + "'.");
} else {
string path = GetString (atts, "VirtualPath", null);
if (path != null)
masterType = MasterPageParser.GetCompiledMasterType (path, HttpContext.Current.Request.MapPath (path), HttpContext.Current);
else
ThrowParseException ("The MasterType directive must have either a TypeName or a VirtualPath attribute.");
}
AddAssembly (masterType.Assembly, true);
}
else
base.AddDirective (directive, atts);
}
#endif

static string SuggestCulture (string culture)
{
string retval = null;
Expand Down Expand Up @@ -343,6 +370,10 @@ protected override Type CompileIntoType ()
internal string MasterPageFile {
get { return masterPage; }
}

internal Type MasterType {
get { return masterType; }
}
#endif
}
}
Expand Down

0 comments on commit f3846ab

Please sign in to comment.