/// <summary> /// Calls the underlying ASP.NET infrastructure to obtain the compiled page type /// relative to the current <see cref="System.Web.HttpRequest.CurrentExecutionFilePath"/>. /// </summary> /// <param name="pageUrl"> /// The filename of the ASPX page relative to the current <see cref="System.Web.HttpRequest.CurrentExecutionFilePath"/> /// </param> /// <returns> /// The <see cref="System.Type"/> of the ASPX page /// referred to by the supplied <paramref name="pageUrl"/>. /// </returns> public static Type GetCompiledPageType(string pageUrl) { if (s_log.IsDebugEnabled) { s_log.Debug("getting page type for " + pageUrl); } string rootedVPath = WebUtils.CombineVirtualPaths(VirtualEnvironment.CurrentExecutionFilePath, pageUrl); if (s_log.IsDebugEnabled) { s_log.Debug("page vpath is " + rootedVPath); } Type pageType = VirtualEnvironment.GetCompiledType(rootedVPath); //#if NET_2_0 // pageType = BuildManager.GetCompiledType( rootedVPath ); // requires rooted virtual path! //#else // pageType = CreatePageInstance(pageUrl).GetType(); //#endif if (s_log.IsDebugEnabled) { s_log.Debug(string.Format("got page type '{0}' for vpath '{1}'", pageType.FullName, rootedVPath)); } return(pageType); }
/// <summary> /// Creates a new instance of the /// <see cref="Spring.Objects.Factory.Support.RootWebObjectDefinition"/> class /// for an .aspx page, providing property values. /// </summary> /// <param name="pageName"> /// Name of the .aspx page to instantiate. /// </param> /// <param name="properties"> /// The <see cref="Spring.Objects.MutablePropertyValues"/> to be applied to /// a new instance of the object. /// </param> public RootWebObjectDefinition( string pageName, MutablePropertyValues properties) : base(WebObjectUtils.GetPageType(pageName), null, properties) { _pageName = WebUtils.CombineVirtualPaths(VirtualEnvironment.CurrentExecutionFilePath, pageName); }
/// <summary> /// Create an object definition name for the given page path /// </summary> protected virtual string CreatePageDefinitionName(string url) { string objectName; objectName = WebUtils.CombineVirtualPaths(VirtualEnvironment.CurrentExecutionFilePath, url); string appPath = VirtualEnvironment.ApplicationVirtualPath; if (objectName.ToLower().StartsWith(appPath.ToLower())) { objectName = objectName.Substring(appPath.Length - 1); } // System.Web.UI.Page page = (System.Web.UI.Page)WebObjectUtils.CreatePageInstance(url); //#if NET_2_0 // objectName = page.AppRelativeVirtualPath.Substring(1); //#else // string appPath = HttpContext.Current.Request.ApplicationPath.TrimEnd('\\', '/'); // objectName = page.TemplateSourceDirectory.TrimEnd('\\','/') + "/" + WebUtils.GetPageName(url) + ".aspx"; // if (objectName.ToLower().StartsWith(appPath.ToLower())) // { // objectName = objectName.Substring(appPath.Length); // } //#endif return(objectName); }
/// <summary> /// Create an object definition name for the given page path /// </summary> protected virtual string CreatePageDefinitionName(string url) { string objectName; objectName = WebUtils.CombineVirtualPaths(VirtualEnvironment.CurrentExecutionFilePath, url); string appPath = VirtualEnvironment.ApplicationVirtualPath; if (objectName.ToLower().StartsWith(appPath.ToLower())) { objectName = objectName.Substring(appPath.Length - 1); } return(objectName); }
/// <summary> /// Gets the controls type from a given filename /// </summary> public static Type GetControlType(string controlName) { AssertUtils.ArgumentHasText(controlName, "controlName"); if (s_log.IsDebugEnabled) { s_log.Debug("getting control type for " + controlName); } // HttpContext ctx = HttpContext.Current; // if (ctx == null) // { // throw new ObjectCreationException( "Unable to get control type. HttpContext is not defined." ); // } string rootedVPath = WebUtils.CombineVirtualPaths(VirtualEnvironment.CurrentExecutionFilePath, controlName); if (s_log.IsDebugEnabled) { s_log.Debug("control vpath is " + rootedVPath); } Type controlType; try { //#if NET_2_0 // controlType = BuildManager.GetCompiledType( rootedVPath ); // requires rooted virtual path! //#else // controlType = (Type) miGetCompiledUserControlType.Invoke(null, new object[] { rootedVPath, null, ctx }); //#endif controlType = VirtualEnvironment.GetCompiledType(rootedVPath); } catch (HttpException httpEx) { // for better error-handling suppress 404 HttpExceptions here if (httpEx.GetHttpCode() == 404) { throw new FileNotFoundException(string.Format("Control '{0}' does not exist", rootedVPath)); } throw; } if (s_log.IsDebugEnabled) { s_log.Debug(string.Format("got control type '{0}' for vpath '{1}'", controlType.FullName, rootedVPath)); } return(controlType); }
/// <summary> /// Calls the underlying ASP.NET infrastructure to obtain the compiled page type /// relative to the current <see cref="System.Web.HttpRequest.CurrentExecutionFilePath"/>. /// </summary> /// <param name="pageUrl"> /// The filename of the ASPX page relative to the current <see cref="System.Web.HttpRequest.CurrentExecutionFilePath"/> /// </param> /// <returns> /// The <see cref="System.Type"/> of the ASPX page /// referred to by the supplied <paramref name="pageUrl"/>. /// </returns> public static Type GetCompiledPageType(string pageUrl) { if (s_log.IsDebugEnabled) { s_log.Debug("getting page type for " + pageUrl); } string rootedVPath = WebUtils.CombineVirtualPaths(VirtualEnvironment.CurrentExecutionFilePath, pageUrl); if (s_log.IsDebugEnabled) { s_log.Debug("page vpath is " + rootedVPath); } Type pageType = VirtualEnvironment.GetCompiledType(rootedVPath); if (s_log.IsDebugEnabled) { s_log.Debug(string.Format("got page type '{0}' for vpath '{1}'", pageType.FullName, rootedVPath)); } return(pageType); }