思考并回答以下问题:
介绍
定义
使多个对象都有机会处理请求,从而避免了请求的发送者和接受者之间的耦合关系。将这些对象连成一条链,并沿着这条链传递该请求,直到有对象处理它为止。
组成部分
The classes and objects participating in this pattern are:
Handler (Approver)
defines an interface for handling the requests(optional) implements the successor link
ConcreteHandler (Director, VicePresident, President)
handles requests it is responsible for can access its successor if the ConcreteHandler can handle the request, it does so; otherwise it forwards the request to its successor
Client (ChainApp)
initiates the request to a ConcreteHandler object on the chain
结构
ChainOfResponsibilityStructure.cs
1 | using UnityEngine; |