public Type GetCompiledType(string virtualPath) { string rootedVPath = WebUtils.CombineVirtualPaths(CurrentExecutionFilePath, virtualPath); Type type = BuildManager.GetCompiledType(rootedVPath); return(type); }
private void CombineVirtualPathsSuite(string appPath) { Assert.AreEqual("/myotherdir/mypath", WebUtils.CombineVirtualPaths("/myotherdir", "mypath")); Assert.AreEqual("/mypath", WebUtils.CombineVirtualPaths("/irrelevantdir", "/mypath")); // note: that's the difference from CreateAbsolutePath() Assert.AreEqual(appPath + "mypath", WebUtils.CombineVirtualPaths("/irrelevantdir", "~/mypath")); Assert.AreEqual(appPath + "some/~/mypath", WebUtils.CombineVirtualPaths("/mydir", "~/some/~/mypath")); Assert.AreEqual("/mydir/some/~/mypath", WebUtils.CombineVirtualPaths("/mydir", "some/~/mypath")); Assert.AreEqual("/myotherdir/mypath/my.file", WebUtils.CombineVirtualPaths("/myotherdir/some.file", "mypath/my.file")); Assert.AreEqual(appPath + "mypath/my.file", WebUtils.CombineVirtualPaths("/myotherdir/some.file", "~/mypath/my.file")); }
public object CreateInstanceFromVirtualPath(string virtualPath, Type requiredBaseType) { string rootedVPath = WebUtils.CombineVirtualPaths(CurrentExecutionFilePath, virtualPath); object result = BuildManager.CreateInstanceFromVirtualPath(rootedVPath, requiredBaseType); if (!requiredBaseType.IsAssignableFrom(result.GetType())) { throw new HttpException(string.Format("Type '{0}' from virtual path '{1}' does not inherit from '{2}'", result.GetType(), rootedVPath, requiredBaseType)); } return(result); }
public object CreateInstanceFromVirtualPath(string virtualPath, Type requiredBaseType) { string rootedVPath = WebUtils.CombineVirtualPaths(CurrentExecutionFilePath, virtualPath); object result; #if NET_1_1 HttpContext ctx = HttpContext.Current; string physicalPath = ctx.Server.MapPath(rootedVPath); result = PageParser.GetCompiledPageInstance(virtualPath, physicalPath, ctx); #else result = BuildManager.CreateInstanceFromVirtualPath(rootedVPath, requiredBaseType); #endif if (!requiredBaseType.IsAssignableFrom(result.GetType())) { throw new HttpException(string.Format("Type '{0}' from virtual path '{1}' does not inherit from '{2}'", result.GetType(), rootedVPath, requiredBaseType)); } return(result); }
public Type GetCompiledType(string virtualPath) { string rootedVPath = WebUtils.CombineVirtualPaths(CurrentExecutionFilePath, virtualPath); Type type = null; #if NET_1_1 if (virtualPath.EndsWith(".aspx")) { type = CreateInstanceFromVirtualPath(virtualPath, typeof(Page)).GetType(); } else if (virtualPath.EndsWith(".ascx")) { type = (Type)miGetCompiledUserControlType.Invoke(null, new object[] { rootedVPath, null, HttpContext.Current }); } #else type = BuildManager.GetCompiledType(rootedVPath); // requires rooted virtual path! #endif return(type); }
/// <summary> /// Returns an the compiled type of the specified file. /// </summary> public static Type GetCompiledType(string virtualPath) { string rootedVPath = WebUtils.CombineVirtualPaths(instance.CurrentExecutionFilePath, virtualPath); return(instance.GetCompiledType(rootedVPath)); }
/// <summary> /// Returns an instance of the specified file. /// </summary> public static object CreateInstanceFromVirtualPath(string virtualPath, Type requiredBaseType) { string rootedVPath = WebUtils.CombineVirtualPaths(instance.CurrentExecutionFilePath, virtualPath); return(instance.CreateInstanceFromVirtualPath(rootedVPath, requiredBaseType)); }
public void CombineVirtualPathsDoesntAcceptNonRootedRoot() { WebUtils.CombineVirtualPaths("mypath", string.Empty); }
public void CombineVirtualPathsDoesntAcceptEmptyRoot() { WebUtils.CombineVirtualPaths(string.Empty, string.Empty); }
public void CombineVirtualPathsDoesntAcceptNullRoot() { WebUtils.CombineVirtualPaths(null, string.Empty); }
public void CombineVirtualPathsDoesntAcceptNonRootedRoot() { Assert.Throws <ArgumentException>(() => WebUtils.CombineVirtualPaths("mypath", string.Empty)); }
public void CombineVirtualPathsDoesntAcceptEmptyRoot() { Assert.Throws <ArgumentNullException>(() => WebUtils.CombineVirtualPaths(string.Empty, string.Empty)); }