I have some weird about compiler error result,
this below after revision.
+++ Unit SingletonConnection +++
TSingletonConnection = class
private
class var FInstance:TSingletonConnection;
FZConnection:TZConnection;
public
Constructor Create;
class function Singleton: TSingletonConnection;
class destructor EofConnection;
function GetSingletonConnection:TZConnection;
end;
implementation
var
Connection:TSingletonConnection;
{ TModelConnection }
constructor TSingletonConnection.Create;
begin
FZConnection:=TZConnection.Create(nil);
end;
class function TSingletonConnection.Singleton: TSingletonConnection;
begin
if not Assigned(FInstance) then
FInstance:=TSingletonConnection.Create;
Result:=FInstance;
end;
class destructor TSingletonConnection.EofConnection;
begin
if Assigned(FInstance) then
FInstance.Free;
end;
function TSingletonConnection.GetSingletonConnection: TZConnection;
begin
Connection:=TSingletonConnection.Singleton;
Result:=Connection.FZConnection;
end;
+++ Unit ModelConnection.pas +++
TModelConnection = class
private
FSingleton:TSingletonConnection;
FConnection:TZConnection;
FDbSettings:TDbSettings;
public
Constructor Create;
end;
implementation
{ TModelConnection }
constructor TModelConnection.Create;
begin
FSingleton:=TSingletonConnection.Singleton;
FConnection:=FSingleton.GetModelConnection;
FDbSettings:=TDbSettings.Create;
with FConnection do
begin
Protocol:=FDbSettings.DbProtocol;
Hostname:=FDbSettings.DbHost;
Port:=FDbSettings.DbPort;
Database:=FDbSettings.DbPath+FDbSettings.DbName;
User:=FDbSettings.DbUser;
Password:=FDbSettings.DbPassword;
LibraryLocation:=FDbSettings.DbLibrary;
end;
end;
I've got error :
Error Identifier ident no Member "GetModelConnection"
But on my previous script (on attachment) was okay.
May i know what's missing from it ?
Thanks a lot
Note : it's was error because Lazarus only show method GetModelConnection from same filename singletonconnection.pas (on folder model), but on my TSingletonConnection, it was write with GetSingletonConnection, filename singletonconnection.pas (on folder controller).