昨天我自己引用了一个国外的网页,是关于MVC的,也是给大家做参考的,其实他所理解的MVC我不完全赞成,现将我的MVC 实现公布
下面是C控制层的代码!!!
{*******************************************************}
{ unit name: Controller }
{ class: TProgramController }
{ descripate: 此Class为MVC中的控制层, }
{ 担任着程序流程的调度工作 }
{ blog : http://blog.csdn.net/zhuam }
{ 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;
{-----------------------------------
descripate: 用于分发程序的业务流程
------------------------------------}
type
TProgramController=class(TObject)
private
TempModelClass:IProgramModel; //业务逻辑Class <Base Model>
public
procedure portal(FView:TForm;sOperator:string);
end;
implementation
uses Util, UnitMVCExample;
{ TProgramController }
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中的反射,根据名称产生Class实例
TempModelClass:=(ClassTemp.Create(nil) as IProgramModel);
TempModelClass.Execute(FView);
end;
except
//raise
end;
end;
initialization
RegisterClass(TForm1Model);
end.
本文地址:http://com.8s8s.com/it/it4703.htm