//1
var
MainWindow: TMainWindow;
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TMainWindow, MainWindow);
ApplicationFacade.Startup(MainWindow);
Application.Run;
end.
//2
function ApplicationFacade: IApplicationFacade;
begin
Result := (TApplicationFacade.Instance as IApplicationFacade)
end;
//3
procedure TFacade.InitializeFacade;
begin
InitializeModel;
InitializeController;
InitializeView;
end;
//4 TApplicationFacade 呼叫父類的註冊命令方法
procedure TApplicationFacade.InitializeController();
begin
/// call inherited to use the PureMVC Controller Singleton.
inherited;
/// Otherwise, if you're implmenting your own
/// IController, then instead do:
/// if Assigned(FController) then Exit;
/// FController = MyAppController.getInstance;
/// do any special subclass initialization here
/// such as registering Commands
RegisterCommand(MSG.Startup, TStartupCommand);
RegisterCommand(MSG.DELETE_USER, TDeleteUserCommand);
RegisterCommand(MSG.ADD_ROLE_RESULT, TAddRoleResultCommand);
end;
//5 TFacade 呼叫控制器註冊命令方法
procedure TFacade.RegisterCommand(NotificationName: string;
CommandClass: TClass);
begin
FController.RegisterCommand(NotificationName, CommandClass);
end;
procedure TController.RegisterCommand(NotificationName: string; CommandType: TClass);
begin
Assert(CommandType.InheritsFrom(TCommand));//是否繼承自TCommand
TMonitor.Enter(FSyncRoot);
try
if FCommandMap.ContainsKey(NotificationName) then Exit;//註冊過的命令則放棄
// This call needs to be monitored carefully. Have to make sure that RegisterObserver
// doesn't call back into the controller, or a dead lock could happen.
FView.RegisterObserver(NotificationName, TObserver.Create('ExecuteCommand', Self));//檢視註冊觀察者,收到此訊息時即可呼叫訊息對應的命類的執行方法
FCommandMap.Add(NotificationName, TCommandClass(CommandType));//控制器命令列表中增加新命令
finally
TMonitor.Exit(FSyncRoot);
end;
end;
pureMVC學習之一
相關文章
- PureMVC學習筆記REMMVC筆記
- MySQL學習筆記之一MySql筆記
- Machine Learning(機器學習)之一Mac機器學習
- Elasticsearch聚合學習之一:基本操作Elasticsearch
- jackson學習之一:基本資訊
- JUnit5學習之一:基本操作
- FFmpeg學習之一(FFmpeg原始碼編譯)原始碼編譯
- 最全SpringBoot學習教程,程式設計師必學之一Spring Boot程式設計師
- 數字人粒子系統學習筆記之一筆記
- 演算法學習之一:3SUM變體演算法
- docker 學習之一 裝MySQL 供遠端使用 LinuxDockerMySqlLinux
- hive學習筆記之一:基本資料型別Hive筆記資料型別
- 統計學習方法c++實現之一 感知機
- Flutter筆記——幀繪製系列之一(原始碼學習)Flutter筆記原始碼
- 系統學習iOS動畫之一:檢視動畫iOS動畫
- 大資料框架之一——Hadoop學習第四天大資料框架Hadoop
- Python學習系列之一: python相關環境的搭建Python
- Kubernetes原始碼學習之一:下載和編譯原始碼原始碼編譯
- Laravel 學習筆記之一:備份資料以及資料填充Laravel筆記
- 資料倉儲建模工具之一——Hive學習第四天Hive
- SpringCloud學習系列之一 ----- 搭建一個高可用的註冊中心(Eureka)SpringGCCloud
- 資料倉儲建模工具之一——Hive學習第五天Hive
- 資料倉儲建模工具之一——Hive學習第七天Hive
- gRPC學習之一:在CentOS7部署和設定GORPCCentOSGo
- OpenGL筆記之一 開學筆記
- Linux學習系列之一:在centos 7.5上安裝nginx 以及簡單配置LinuxCentOSNginx
- iOS開發從零學習Flutter之一在mac上安裝FlutteriOSFlutterMac
- 入選《時代》的科學牛人,人工智慧和機器學習最權威的學者之一人工智慧機器學習
- Node.js入門教學之一Node.js
- Laravel-admin 學習筆記之一:select 聯動選單進行篩選資料Laravel筆記
- SAP HANA Cloud 學習教程之一: 如何在 SAP BTP 上建立 SAP HANA Cloud 例項Cloud
- spring4.1.8初始化原始碼學習三部曲之一:AbstractApplicationContext構造方法Spring原始碼APPContext構造方法
- git實用複習篇之一步到位!Git
- 深度學習——學習目錄——學習中……深度學習
- SQL經典練習題48道之一(1-10)SQL
- 深度學習學習框架深度學習框架
- 學習ThinkPHP,學習OneThinkPHP
- ICML2019 | 深度學習鼻祖之一Bengio提出並開源圖馬爾科夫神經網路深度學習馬爾科夫神經網路
- 強化學習-學習筆記3 | 策略學習強化學習筆記