Delphi MVC implementation

xiaoxiao2021-03-06  96

Yesterday I cited a foreign web page. It is about MVC. It is also for everyone. In fact, I am not fully approved by the MVC, now I will announce the code of the C control layer! ! ! {********************************************************** ******} {Unit name: controller} {class: tprogramController} {description: This class is the control layer in the MVC,} {BLOG: http://blog.9cbs {Author: zhuam} {date: 2004/10/25} {CopyRight (c) 1.0} {******************************** ***************************************}

Unit controller;

Interface

Uses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls, Mask, Extctrls, Model

{--------------------------------- Description: Business process for distribution programs ----- ------------------------------} Type tprogramcontroller = class (TOBJECT) Private TempModelclass: iprogrammodel; // Business logic Class < Base Model> Public Procedure Portal (Fview: TForm; Soperator: String);

END;

IMPLEMentation

Uses util, unitmvcexample;

{TPROGRAMCONTROLLLER}

procedure TProgramController.portal (FView: TForm; sOperator: string); var ClassTemp: TComponentClass; SListRead: TSListReader; XMLRead: TXMLReader; sModel: string; begin try SListRead: = TSListReader.Create; XMLRead: = TXMLReader.Create; sModel: = SListRead.getSListDataToModelString (XMLRead.getXMLDataToList, FView.Name, sOperator); if Trim (sModel) <> '' then begin ClassTemp: = TComponentClass (getClass (sModel)); // java similarly reflected in the generated instance according Class name TempModelclass: = (classtemp.create (nil) as iprogrammodel; tempmodelclass.execute (fview); end; eXCEPT // raise end; end; Initialization

RegisterClass (TFORM1MODEL);

End.

转载请注明原文地址:https://www.9cbs.com/read-97503.html

New Post(0)