📄 udaofactory.pas
字号:
unit uDaoFactory;
interface
uses
DB, ADODB, uDatabasePublic, uMemberDAO;
type
//==============================================================================
// 抽象DAO工厂类
//==============================================================================
{ TDaoFactory }
TDaoFactory = class(TObject)
private
protected
fConn : TCustomConnection;
function getConnection : TCustomConnection;
procedure setConnection(pConnection: TCustomConnection);
public
constructor Create;
destructor Destroy; override;
//创建工厂类
class function getDaoFactory(const dbtype: TDBKind): TDaoFactory;
//建立与数据库的连接
//function createConnection : TCustomConnection; virtual; abstract;
function getMemberDAO : IMemberDAO; virtual; abstract;
published
property Connection : TCustomConnection read getConnection write setConnection;
end;
implementation
uses uMssqlDaoFactory;
{ TDaoFactory }
constructor TDaoFactory.Create;
begin
//
end;
destructor TDaoFactory.Destroy;
begin
fconn.Free;
inherited;
end;
function TDaoFactory.getConnection: TCustomConnection;
begin
result := fConn;
end;
class function TDaoFactory.getDaoFactory(const dbtype: TDBKind): TDaoFactory;
begin
case dbtype of
dbMSSQL :
result := TMssqlDaoFactory.Create;
else
//
end;
end;
procedure TDaoFactory.setConnection(pConnection: TCustomConnection);
begin
fConn := pConnection;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -