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

推荐订阅源

博客园_首页
Security Archives - TechRepublic
Security Archives - TechRepublic
Application and Cybersecurity Blog
Application and Cybersecurity Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
CERT Recently Published Vulnerability Notes
S
Security @ Cisco Blogs
S
Security Affairs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
Lohrmann on Cybersecurity
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News: Ask HN
Hacker News: Ask HN
Forbes - Security
Forbes - Security
H
Heimdal Security Blog
A
Arctic Wolf
NISL@THU
NISL@THU
P
Proofpoint News Feed
W
WeLiveSecurity
S
Schneier on Security
AI
AI
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
L
LINUX DO - 最新话题
Cisco Talos Blog
Cisco Talos Blog
AWS News Blog
AWS News Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Know Your Adversary
Know Your Adversary
Scott Helme
Scott Helme
V
Vulnerabilities – Threatpost
Cyberwarzone
Cyberwarzone
I
Intezer
S
Securelist
Help Net Security
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
小众软件
小众软件
Last Week in AI
Last Week in AI
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
WordPress大学
WordPress大学
罗磊的独立博客
月光博客
月光博客
雷峰网
雷峰网
A
About on SuperTechFans
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
博客园 - 司徒正美
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events

博客园 - 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
>
    
{

    }