⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ufacade.pas

📁 这是不可多得的源代码
💻 PAS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -