/// <summary> /// 为页面挂接PageModule /// </summary> /// <param name="page"></param> public static void AttachPageModules(this Page page) { if (page != null) { foreach (IPageModule module in ConfigSectionFactory.GetPageModulesSection().Create().Values) { module.Init(page); } } }
/// <summary> /// 根据ContentTypeKey,得到Response的ContentType /// </summary> /// <param name="key">ContentTypeKey</param> /// <returns>ContentType</returns> /// <remarks>根据ContentTypeKey,得到Response的ContentType</remarks> public static string GetContentTypeByKey(string key) { ContentTypesSection section = ConfigSectionFactory.GetContentTypesSection(); key = key.ToLower(); ContentTypeConfigElement elt = section.ContentTypes[key]; string contentType = elt != null ? elt.ContentType : string.Empty; return(contentType); }
private static void PageLoadHandler(object sender, EventArgs e) { HttpContext.Current.LoadConfigPageContent(true); if (((Page)sender).IsPostBack) { AutoEncryptControlValueHelper.DecryptControlsValue( ConfigSectionFactory.GetPageExtensionSection().AutoEncryptControlIDs.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries), (Page)sender); } }
/// <summary> /// 向页面添加配置扩展信息 /// </summary> /// <param name="context">HttpContext</param> /// <param name="checkAutoLoad"></param> public static void LoadConfigPageContent(this HttpContext context, bool checkAutoLoad) { if (context != null) { PageContentSection section = ConfigSectionFactory.GetPageExtensionSection(); Page page = context.GetCurrentPage(); if (page != null) { if (checkAutoLoad) { if (section.AutoLoad == false) { return; } if (page.Header == null) { return; } string headerAutoLoad = page.Header.Attributes["autoLoad"]; if (headerAutoLoad.IsNotEmpty() && headerAutoLoad.ToLower() == "false") { return; } } if (WebAppSettings.IsWebApplicationCompilationDebug()) { RegisterCssInHeader(page, section.CssClasses.Debug); } else { RegisterCssInHeader(page, section.CssClasses.Release); } RegisterCssInHeader(page, section.CssClasses.All); if (WebAppSettings.IsWebApplicationCompilationDebug()) { RegisterScriptInHeader(page, section.Scripts.Debug); } else { RegisterScriptInHeader(page, section.Scripts.Release); } RegisterScriptInHeader(page, section.Scripts.All); } } }
private void PreRequestHandlerExecuteHandler(object sender, EventArgs e) { Page page = HttpContext.Current.CurrentHandler as Page; if (page != null) { _PageModules = ConfigSectionFactory.GetPageModulesSection().Create(); foreach (IPageModule module in _PageModules.Values) { module.Init(page); } } }
private void page_PreRenderComplete(object sender, EventArgs e) { RegisterDefaultNameTable(); AutoEncryptControlValueHelper.EncryptControlsValue( ConfigSectionFactory.GetPageExtensionSection().AutoEncryptControlIDs.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries), (Page)sender); PerformanceMonitorHelper.GetDefaultMonitor().WriteExecutionDuration("PageContentModule-RecursiveTranslate", () => TranslatorControlHelper.RecursiveTranslate((Page)sender)); DeluxeNameTableContextCache.Instance.RegisterNameTable((Page)sender); ((Page)sender).ClientScript.RegisterClientScriptBlock(this.GetType(), "DeluxeApplicationPath", string.Format("var _DeluxeApplicationPath = \"{0}\";", HttpContext.Current.Request.ApplicationPath), true); }
/// <summary> /// 根据文件扩展名,得到Response的ContentType /// </summary> /// <param name="fileExtesionName">文件扩展名</param> /// <returns>ContentType</returns> /// <remarks>根据文件扩展名,得到Response的ContentType</remarks> public static string GetContentTypeByFileExtesionName(string fileExtesionName) { string result = string.Empty; ContentTypesSection section = ConfigSectionFactory.GetContentTypesSection(); foreach (ContentTypeConfigElement elt in section.ContentTypes) { if (StringInCollection(fileExtesionName, elt.FileExtensionNames, true)) { result = elt.ContentType; break; } } return(result); }
/// <summary> /// Init HttpModule /// </summary> /// <param name="context"></param> protected virtual void Init(HttpApplication context) { _HttpModuleCollection = new Dictionary <string, IHttpModule>(); HttpModulesSection moduleSection = ConfigSectionFactory.GetHttpModulesSection(); foreach (HttpModuleAction moduleAction in moduleSection.Modules) { try { IHttpModule module = (IHttpModule)TypeCreator.CreateInstance(moduleAction.Type); this._HttpModuleCollection.Add(moduleAction.Name, module); module.Init(context); } catch (TypeLoadException ex) { ex.TryWriteAppLog(); } } }