惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Archives - TechRepublic
Security Archives - TechRepublic
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AWS News Blog
AWS News Blog
S
SegmentFault 最新的问题
T
Tailwind CSS Blog
The Hacker News
The Hacker News
GbyAI
GbyAI
P
Palo Alto Networks Blog
博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
Stack Overflow Blog
Stack Overflow Blog
博客园 - Franky
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Cyberwarzone
Cyberwarzone
H
Help Net Security
S
Securelist
月光博客
月光博客
博客园 - 【当耐特】
T
Threatpost
T
Tenable Blog
G
GRAHAM CLULEY
博客园 - 司徒正美
I
Intezer
MyScale Blog
MyScale Blog
T
Threat Research - Cisco Blogs
P
Privacy & Cybersecurity Law Blog
The GitHub Blog
The GitHub Blog
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
Google DeepMind News
Google DeepMind News
C
Cybersecurity and Infrastructure Security Agency CISA
罗磊的独立博客
腾讯CDC
P
Privacy International News Feed
博客园_首页
The Cloudflare Blog
Cisco Talos Blog
Cisco Talos Blog
A
About on SuperTechFans
V
Vulnerabilities – Threatpost
A
Arctic Wolf
B
Blog RSS Feed
Recorded Future
Recorded Future
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
S
Security Affairs
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog

博客园 - karoc

《重构-改善既有代码的设计》读书笔记 扩展GridView,增加单选按钮列 任务开始时间和完成时间 最大长度验证控件:MaxLengthValidator 又是关于AjaxControlToolkit的ModalPopup的问题 有个总结 使用svn的小插曲 开发小经验总结(不断更新) 今天发现一个VS2008中文版和英文版的差别 解决DocType引起AjaxTookit的ModulPopup显示异常问题的方法 Reporting Services 2005 常见问题解决方法(不断更新) 用VSTO开发Project插件心得 自定义MemberShipProvider和PersonalizationProvider使用WebParts实现个性化页面 在线修改KeyValue配置节 改造Duwamish中的Configuration 直接用Response输出可以加批注的Excel C#控制Windows Messenger和Windows Live Messenger窗口发送消息 一个读取扩展名为xml的资源文件的方法 用C#+WMI实现获取w3wp进程对应的应用程序池
瞎搞八搞,另类PageBase
karoc · 2007-05-30 · via 博客园 - karoc

图:

代码:

public class PageBase<PageLayout, PageSecurity, PageError>
        : System.Web.UI.Page
        where PageLayout : IPageLayout, 
new ()
        where PageSecurity : IPageSecurity, 
new()
        where PageError : IPageError, 
new()
    
{
        
protected override void OnPreInit(EventArgs e)
        
{
            PerformSecurity();
            PerformLayout();
            
base.OnPreInit(e);
        }


        
protected override void OnError(EventArgs e)
        
{
            PerformPageError();
            
base.OnError(e);
        }


        
/// <summary>
        
/// 处理页面错误
        
/// </summary>

        protected void PerformPageError()
        
{
            PageError handler 
= GetInstance<PageError>();
            handler.HandleError(
this);
        }


        
/// <summary>
        
/// 设置MasterPage
        
/// </summary>

        protected void PerformLayout()
        
{
            PageLayout layout 
= GetInstance<PageLayout>();
            
this.MasterPageFile = layout.Layout;
        }


        
/// <summary>
        
/// 设置权限
        
/// </summary>

        protected void PerformSecurity()
        
{
            PageSecurity security 
= GetInstance<PageSecurity>();
            security.ControlSecurity();
        }


        
/// <summary>
        
/// 获取一个类型的实例
        
/// </summary>
        
/// <typeparam name="T"></typeparam>
        
/// <returns></returns>

        protected T GetInstance<T>() where T : new()
        
{
            
return new T();
        }

    }

子类只要组合模块就能形成丰富多样的PageBase:

public class PageBase : sssss.PageBase<
        LayoutProvider, 
        sssss.PageSecurityLess,
        PageErrorHandler
>
    
{

    }