ufacade.pas
来自「这是不可多得的源代码」· PAS 代码 · 共 54 行
PAS
54 行
unit uFacade;
interface
uses
SysUtils, Variants, Classes, uObjects;
type
TFacade = class(TObject)
private
obj1Factory : TObj1Factory;
obj2Factory : TObj2Factory;
obj3Factory : TObj3Factory;
public
function CreateObject1 : TObject1;
function CreateObject2 : TObject2;
function CreateObject3 : TObject3;
Destructor Destroy; override;
end;
implementation
{ TFacade }
function TFacade.CreateObject1: TObject1;
begin
if (obj1Factory = nil) then
obj1Factory := TObj1Factory.Create;
Result := Obj1Factory.CreateObject1;
end;
function TFacade.CreateObject2: TObject2;
begin
if (obj2Factory = nil) then
obj2Factory := TObj2Factory.Create;
Result := Obj2Factory.CreateObject2;
end;
function TFacade.CreateObject3: TObject3;
begin
if (obj3Factory = nil) then
obj3Factory := TObj3Factory.Create;
Result := Obj3Factory.CreateObject3;
end;
destructor TFacade.Destroy;
begin
FreeAndNil(Obj1Factory);
FreeAndNil(Obj2Factory);
FreeAndNil(Obj3Factory);
inherited;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?