zoukankan
html css js c++ java
责任链
1:意图
为解除请求的发送者和接收者之间耦合,而使多个对象都有机会处理这个请求。将这些对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理它。
2:类图
3:代码
namespace
Bll.ChainOfResponsibility
{
public
class
MSGEntity
{
//
信息内容
private
string
content;
public
string
Content
{
get
{
return
content; }
set
{ content
=
value; }
}
//
审核级别
private
int
level
=
0
;
public
int
Level
{
get
{
return
level; }
set
{ level
=
value; }
}
}
public
abstract
class
Man
{
protected
Man _man;
public
abstract
void
Read(MSGEntity entity);
public
void
SetSuccessor(Man man)
{
this
._man
=
man;
}
}
public
class
Employee : Man
{
const
int
level
=
1
;
public
override
void
Read(MSGEntity entity)
{
if
(
object
.Equals(level, entity.Level))
{
//
}
else
if
(
base
._man
!=
null
)
{
_man.Read(entity);
}
}
}
public
class
Leader : Man
{
const
int
level
=
2
;
public
override
void
Read(MSGEntity entity)
{
if
(
object
.Equals(level, entity.Level))
{
//
}
else
if
(
base
._man
!=
null
)
{
_man.Read(entity);
}
}
}
public
class
Manage : Man
{
const
int
level
=
3
;
public
override
void
Read(MSGEntity entity)
{
if
(
object
.Equals(level, entity.Level))
{
//
}
else
if
(
base
._man
!=
null
)
{
_man.Read(entity);
}
}
}
}
//
调用
Employee employ
=
new
Employee();
Leader leader
=
new
Leader();
Manage manage
=
new
Manage();
employ.SetSuccessor(leader);
leader.SetSuccessor(manage);
employ.Read(
new
MSGEntity());
查看全文
相关阅读:
thinkphp框架 url 去除index.php
读yaml文件警告: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. data = yaml.load(fr)
Appium 坐标定位元素
Appium操作app弹窗
AirtestIDE 教程(二)
AirtestIDE 教程(一)
Appium(五) aapt 不是内部或外部命令
Appium(四) selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: You must include a platformName capability
Appium(三) 打开 uiautomatorviewer.bat 闪退问题
Appium(二) 下载安装 appium-python-client
原文地址:https://www.cnblogs.com/tommyli/p/1228254.html
最新文章
mysql
SpringBoot2.X整合Redis
MySQL
Java反射
Java多线程
SpringBoot 集成 Okhttp3
Maven pom.xml 全配置
Spring Boot2.0整合logback日志
SpringBoot2使用Spring Data-JPA实现增删改查
Thymemeaf
热门文章
SpringBoot整合日期转换器
PHP 时间戳超过2038年以后的解决方法
PHP 通过CURL上传文件到另一台服务器
PHP 上传文件出现 500 Internal server error 解决方法
PHP 理解ob_flush和flush的区别
浅谈Mysql共享锁、排他锁、悲观锁、乐观锁及其使用场景
apache环境下 tp框架 在输入url后出现 No input file specified 解决方法
设置调试工具XDebug PHPStorm IDE
Nginx教程(7) 正向代理与反向代理【总结】
JetBrains PhpStorm 破解
Copyright © 2011-2022 走看看