|
Implementing the IOTAFile is simple and straightforward.
|
IOTAFile = interface(IUnknown)
['{6E2AD9B0-F7F0-11D1-AB26-00C04FB16FB3}']
function GetSource: string;
function GetAge: TDateTime;
property Source: string read GetSource;
property Age: TDateTime read GetAge;
end; |
|
type
TProjectCreatorFile = class(TInterfacedObject,
IOTAFile)
private
FAge: TDateTime;
FProjectName: string; //
Passed in from the IOTAProjectCreator
public
constructor Create(const ProjectName: string);
function GetSource: string;
function GetAge: TDateTime;
end;
implementation
{ TProjectCreatorFile }
constructor TProjectCreatorFile.Create(const
ProjectName: string);
begin
FAge := -1; // Flag age
as New File
FProjectName := ProjectName;
end;
function TProjectCreatorFile.GetAge: TDateTime;
begin
Result := FAge;
end;
function TProjectCreatorFile.GetSource: string;
begin
Result := ProjectCode_Using_FProjectName_To_Parameterize;
end; |
Now in the IOTAProjectModule.NewProjectSource method simply
creates an instance of this object.
|
function
TIOTAProjectCreator.NewProjectSource(const ProjectName: string): IOTAFile;
begin
Result := TProjectCreatorFile.Create(ProjectName);
end; |

Just to add more confusion as to how the IDE calls the Project
Module creator here is a debug dump including an IOTAFile
implementation to create the source code. This time the
NewProjectResource method is called, first. Also notice that the
IOTAFile has been created before the the call to NewProjectSource
where it is explicitly created..... More mystery.
Now we can create the default Form for the Project. 
|