1. Command类,用来声明执行操作的接口。
Public MustInherit Class Command
Protected mReceiver As Receiver
Public Sub New(ByVal rec As Receiver)
Me.mReceiver = rec
End Sub
Public MustOverride Sub Execute()
End Class
2.ConcreteCommand类,将一个接收者对象绑定于一个动作,调用接收者相应的操作,以实现Execute。
Public Class ConcreteCommand
Inherits Command
Public Sub New(ByVal rec As Receiver)
MyBase.New(rec)
End Sub
Public Overrides Sub Execute()
mReceiver.Action()
End Sub
End Class
3.Invoker类,要求该命令执行这个请求。
Public Class Invoker
Private mCommand As Command
Public Sub SetCommand(ByVal com As Command)
Me.mCommand = com
End Sub
Public Sub ExecuteCommand()
mCommand.Execute()
End Sub
End Class