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

推荐订阅源

The Last Watchdog
The Last Watchdog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 热门话题
G
GRAHAM CLULEY
S
Schneier on Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
Recorded Future
Recorded Future
I
Intezer
云风的 BLOG
云风的 BLOG
博客园 - Franky
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
T
Tenable Blog
The Hacker News
The Hacker News
T
The Blog of Author Tim Ferriss
Attack and Defense Labs
Attack and Defense Labs
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
News and Events Feed by Topic
有赞技术团队
有赞技术团队
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
N
News and Events Feed by Topic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
The Cloudflare Blog
Webroot Blog
Webroot Blog
W
WeLiveSecurity
H
Heimdal Security Blog
博客园 - 三生石上(FineUI控件)
V
Vulnerabilities – Threatpost
G
Google Developers Blog
O
OpenAI News
V
V2EX
罗磊的独立博客
博客园_首页
N
News | PayPal Newsroom
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
TaoSecurity Blog
TaoSecurity Blog
Cloudbric
Cloudbric
H
Hacker News: Front Page
博客园 - 叶小钗
T
Tor Project blog
AI
AI

博客园 - Love Fendi

性能优化系列---查询高cup的sql 8.17--8.24积累 sql server 2005 analysis service step by step(三):创建父子维度 sql server 2005 analysis service step by step(二):创建时间维度 sql serve 2005 analysis service step by step(一):创建标准维度 算法练习五:求数组中第k大的数 算法练习四:求N!不溢出 算法练习三:奇偶分割 算法练习二:二分查找 数据库锁 算法练习一:最大公约数与最小公倍数 索引优化 生成验证码,同时异步获取加密后的验证码 自定义控件中与脚本资源集成的若干处理方式 一条语句删除表中某字段重复的数据 动态按需异步加载js文件 在Nhibernate中使用Json.net中出现Self referencing loop的错误的处理 JQuery学习笔记 c#委托事件 入门
State模式学习
Love Fendi · 2009-11-01 · via 博客园 - Love Fendi

enum DocumentState
{
    readonly,Editable
}


class Document
{
 DocumentState state;
 public void Handle()
 {
  if(state=DocumentState.readonly)
  {
  }
  else
  {
  }
 }
}
-------------------------------------
abstract clasass StatedDocument  ---表达状态及依赖的行为
{
 public abstract void Handle1()
 public abstract void Handle2()
 public abstract void Handle3()
 public abstract StatedDocument Next
        { get;set;}
}

class Document------Request
{
 StatedDocument statedDocument;
 public void SetStatedDocument(StatedDocument statedDocument)
 {
  this.statedDocument=statedDocument;
 }
 public void Handle1()
 {
  statedDocument.Handle1();
 }
 public void Handle2()
 {
  statedDocument.Handle2();
 }
 public void Handle3()
 {
  statedDocument.Handle3();
 }
}

-----------具体的状态类

public class ReadOnlyDocumentState:StatedDocument 

{

   public abstract void Handle1()--------edit button

      {

      system.println(" system is readonly");

      SetStatedDocument(new EditableDocumentState)

      }

}