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

推荐订阅源

Y
Y Combinator Blog
D
Docker
有赞技术团队
有赞技术团队
D
DataBreaches.Net
The GitHub Blog
The GitHub Blog
爱范儿
爱范儿
H
Help Net Security
美团技术团队
MyScale Blog
MyScale Blog
B
Blog RSS Feed
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
G
Google Developers Blog
月光博客
月光博客
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs

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

      }

}