internal Type GetReferencedType(VirtualPath virtualPath, bool allowNoCompile) { virtualPath = base.ResolveVirtualPath(virtualPath); if ((base._pageParserFilter != null) && !base._pageParserFilter.AllowVirtualReference(base.CompConfig, virtualPath)) { base.ProcessError(System.Web.SR.GetString("Reference_not_allowed", new object[] { virtualPath })); } BuildResult vPathBuildResult = null; Type baseType = null; try { vPathBuildResult = BuildManager.GetVPathBuildResult(virtualPath); } catch (HttpCompileException exception) { if (exception.VirtualPathDependencies != null) { foreach (string str in exception.VirtualPathDependencies) { base.AddSourceDependency(VirtualPath.Create(str)); } } throw; } catch { if (this.IgnoreParseErrors) { base.AddSourceDependency(virtualPath); } throw; } BuildResultNoCompileTemplateControl control = vPathBuildResult as BuildResultNoCompileTemplateControl; if (control != null) { if (!allowNoCompile) { return(null); } baseType = control.BaseType; } else { if (!(vPathBuildResult is BuildResultCompiledType)) { throw new HttpException(System.Web.SR.GetString("Invalid_typeless_reference", new object[] { "src" })); } BuildResultCompiledType type2 = (BuildResultCompiledType)vPathBuildResult; baseType = type2.ResultType; } base.AddTypeDependency(baseType); base.AddBuildResultDependency(vPathBuildResult); return(baseType); }
internal void SetNoCompileBuildResult(BuildResultNoCompileTemplateControl noCompileBuildResult) { this._noCompileBuildResult = noCompileBuildResult; }
internal Type GetReferencedType(VirtualPath virtualPath, bool allowNoCompile) { virtualPath = ResolveVirtualPath(virtualPath); // If we have a page parser filter, make sure the reference is allowed if (_pageParserFilter != null && !_pageParserFilter.AllowVirtualReference(CompConfig, virtualPath)) { ProcessError(SR.GetString(SR.Reference_not_allowed, virtualPath)); } BuildResult result = null; Type t = null; try { result = BuildManager.GetVPathBuildResult(virtualPath); } catch (HttpCompileException e) { // Add the path depdencies properly so we know when // to invalidate the cached result. if (e.VirtualPathDependencies != null) { foreach (string vPath in e.VirtualPathDependencies) { AddSourceDependency(VirtualPath.Create(vPath)); } } throw; } catch { // Add the virtualPath to the dependency so that // we know when to check again. This could happen if the // virtualPath points to a file not created yet. // This only affects designtime code path since we do want to return // partial result even if there is an error, and that result is // cached. VSWhidbey 372585 if (IgnoreParseErrors) { AddSourceDependency(virtualPath); } throw; } // Is it a no-compile page/uc BuildResultNoCompileTemplateControl noCompileResult = result as BuildResultNoCompileTemplateControl; if (noCompileResult != null) { // If no-compile is not acceptable, return null if (!allowNoCompile) { return(null); } // In the no-compile case, use the base type, since we don't compile a type t = noCompileResult.BaseType; } else if (result is BuildResultCompiledType) { BuildResultCompiledType compiledResult = (BuildResultCompiledType)result; Debug.Assert(compiledResult != null); t = compiledResult.ResultType; } else { throw new HttpException(SR.GetString(SR.Invalid_typeless_reference, _sourceString)); } Debug.Assert(t != null); // Add a dependency on the Type AddTypeDependency(t); // Add a dependency on the BuildResult AddBuildResultDependency(result); return(t); }