<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ~~~ /* Command 命令模式: 將一個請求封裝為一個對象, 從而使你可用不同的請求對客戶進行參數化; 對請求排隊或者記錄請求日志,以及支持可撤銷的操作 個人想法:Invoker維護請求隊列(Command接口隊列),通過一些函數可以添加、修改、執行請求隊列, 在每一種ConcreteCommand中有對該命令的執行體(Receiver),最終響應請求隊列的命令 作者: HCLAC 日期: 20170310 */ package command import ( "fmt" ) // 命令接口 -- 可以保存在請求隊形中,方便請求隊形處理命令,具體對命令的執行體在實現這個接口的類型結構體中保存著 type Command interface { Run() } // 請求隊形,保存命令列表,在ExecuteCommand函數中遍歷執行命令 type Invoker struct { comlist []Command } // 添加命令 func (i *Invoker) AddCommand(c Command) { if i == nil { return } i.comlist = append(i.comlist, c) } // 執行命令 func (i *Invoker) ExecuteCommand() { if i == nil { return } for _, val := range i.comlist { val.Run() } } func NewInvoker() *Invoker { return &Invoker{[]Command{}} } // 具體命令,實現Command接口,保存一個對該命令如何處理的執行體 type ConcreteCommandA struct { receiver ReceiverA } func (c *ConcreteCommandA) SetReceiver(r ReceiverA) { if c == nil { return } c.receiver = r } // 具體命令的執行體 func (c *ConcreteCommandA) Run() { if c == nil { return } c.receiver.Execute() } func NewConcreteCommandA() *ConcreteCommandA { return &ConcreteCommandA{} } // 針對ConcreteCommand,如何處理該命令 type ReceiverA struct { } func (r *ReceiverA) Execute() { if r == nil { return } fmt.Println("針對ConcreteCommandA,如何處理該命令") } func NewReceiverA() *ReceiverA { return &ReceiverA{} } ////////////////////////////////////////////////////////// // 具體命令,實現Command接口,保存一個對該命令如何處理的執行體 type ConcreteCommandB struct { receiver ReceiverB } func (c *ConcreteCommandB) SetReceiver(r ReceiverB) { if c == nil { return } c.receiver = r } // 具體命令的執行體 func (c *ConcreteCommandB) Run() { if c == nil { return } c.receiver.Execute() } func NewConcreteCommandB() *ConcreteCommandB { return &ConcreteCommandB{} } // 針對ConcreteCommandB,如何處理該命令 type ReceiverB struct { } func (r *ReceiverB) Execute() { if r == nil { return } fmt.Println("針對ConcreteCommandB,如何處理該命令") } func NewReceiverB() *ReceiverB { return &ReceiverB{} } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看