protected Type GetReferencedType (string virtualPath)
{
if (String.IsNullOrEmpty (virtualPath))
throw new ArgumentNullException ("virtualPath");
var pageParserFilter = PageParserFilter;
if (pageParserFilter != null) {
var cfg = WebConfigurationManager.GetSection ("system.web/compilation") as CompilationSection;
if (cfg == null)
throw new HttpException ("Internal error. Missing configuration section.");
string extension = VirtualPathUtility.GetExtension (virtualPath);
Type btype = cfg.BuildProviders.GetProviderTypeForExtension (extension);
VirtualReferenceType reftype;
if (btype == null)
reftype = VirtualReferenceType.Other;
else if (btype == typeof (PageBuildProvider))
reftype = VirtualReferenceType.Page;
else if (btype == typeof (UserControlBuildProvider))
reftype = VirtualReferenceType.UserControl;
else if (btype == typeof (MasterPageBuildProvider))
reftype = VirtualReferenceType.Master;
else
reftype = VirtualReferenceType.SourceFile;
if (!pageParserFilter.AllowVirtualReference (virtualPath, reftype))
throw new HttpException ("The parser does not permit a virtual reference to the UserControl.");
}
return BuildManager.GetCompiledType (virtualPath);
}