Skip to content

Commit

Permalink
Merge branch 'Feature/uGitHUB' into Development
Browse files Browse the repository at this point in the history
  • Loading branch information
JensBorrisholt committed Aug 2, 2020
2 parents a0f9ad6 + 8f1dfcd commit 1bbd436
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
13 changes: 11 additions & 2 deletions Demo Generator/Pkg.Json.DemoGenerator.pas
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ TDemoGenerator = class
procedure UpdateDemoProject;
procedure ModifyDemoHelper;
procedure SetRootDirectory(const Value: string);
procedure SetDestinationDirectory(const Value: string);
published
property RootDirectory: string read FRootDirectory write SetRootDirectory;
property DestinationDirectory : string read FDestinationDirectory;
property DestinationDirectory: string read FDestinationDirectory write SetDestinationDirectory;
property DestinationFrameWork: TDestinationFrameWork read FTDestinationFrameWork write FTDestinationFrameWork;
property DestinationClassName: string read FDestinationClassName write FDestinationClassName;
property DestinationUnitName: string read FDestinationUnitName write FDestinationUnitName;
Expand Down Expand Up @@ -86,7 +87,9 @@ procedure TDemoGenerator.Execute;

FJsonMapper.DestinationClassName := FDestinationClassName;
FJsonMapper.DestinationUnitName := FDestinationUnitName;
FDestinationDirectory := FRootDirectory + FJsonMapper.DestinationClassName + TPath.DirectorySeparatorChar;

if FDestinationDirectory = '' then
FDestinationDirectory := FRootDirectory + FJsonMapper.DestinationClassName + TPath.DirectorySeparatorChar;
TDirectory.CreateDirectory(FDestinationDirectory);

if FFileName = '' then
Expand Down Expand Up @@ -184,6 +187,12 @@ procedure TDemoGenerator.ModifyDemoHelper;
SaveText;
end;

procedure TDemoGenerator.SetDestinationDirectory(const Value: string);
begin
FDestinationDirectory := IncludeTrailingPathDelimiter(Value);
FRootDirectory := FDestinationDirectory;
end;

procedure TDemoGenerator.SetRootDirectory(const Value: string);
begin
FRootDirectory := IncludeTrailingPathDelimiter(Value);
Expand Down
6 changes: 2 additions & 4 deletions Generator GUI/uMainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,13 @@ procedure TMainForm.ActDemoExecute(Sender: TObject);
if not SelectDirectory('Select a directory', Destination, Destination) then
exit;

FJsonMapper.DestinationClassName := Edit1.Text;
FJsonMapper.DestinationUnitName := Edit2.Text;
FJsonMapper.Parse(Memo1.Lines.Text);

with TDemoGenerator.Create do
try
DestinationClassName := Edit1.Text;
DestinationUnitName := Edit2.Text;
DestinationDirectory := Destination;
DestinationFrameWork := TDestinationFrameWork.dfBoth;
Json := Memo1.Text;
Execute;
finally
free;
Expand Down
2 changes: 1 addition & 1 deletion Lib/Pkg.Json.JSONName.pas
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ constructor TJSONName.Create(aItemName: string);

function TJSONName.NameAttribute: string;
begin
exit('[JSONName(' + AnsiQuotedStr(FJsonName, #39) + ')]');
exit('JSONName(' + AnsiQuotedStr(FJsonName, #39) + ')');
end;

procedure TJSONName.SetName(const Value: string);
Expand Down
7 changes: 3 additions & 4 deletions Lib/Pkg.Json.StubField.pas
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function TStubClass.GetImplementationPart: string;
Lines.AddFormat(' %s.Free;', [StubField.FieldName]);

for StubField in FArrayItems do
Lines.AddFormat(' %s.Free;', [StubField.FieldName]);
Lines.AddFormat(' Get%s.Free;', [StubField.PropertyName]);

Lines.Add(' inherited;');
Lines.Add('end;');
Expand Down Expand Up @@ -248,16 +248,15 @@ Lines.Add(Name + ' = class' + IfThen(BaseClass = '', '', '(' + BaseClass + '
if StubField.IsObjectArrayField then
begin
StubArrayField := StubField as TStubArrayField;
Lines.Add(' ' + StubField.NameAttribute);
Lines.Add(' [JSONMarshalled(False)]');
Lines.AddFormat(' [%s, JSONMarshalled(False)]', [StubField.NameAttribute]);
Lines.AddFormat(' %sArray: TArray<%s>;', [StubField.FieldName, StubField.TypeAsString]);
Lines.Add(' [GenericListReflect]');
Lines.AddFormat(' %s: TObjectList<%s>;', [StubField.FieldName, StubArrayField.TypeAsString]);
end
else
begin
if StubField.NeedsAttribute then
Lines.Add(' ' + StubField.NameAttribute);
Lines.AddFormat(' [%s]', [StubField.NameAttribute]);

Lines.AddFormat(' %s: %s;', [StubField.FieldName, StubField.TypeAsString]);
end;
Expand Down
1 change: 1 addition & 0 deletions Unit Test/JsonToDelphiClassTests.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@
<SourceProjectName>C:\Users\Jens Borrisholt\Documents\GitHUB\Delphi-JsonToDelphiClass\Generator GUI\JsonToDelphiClass.dproj</SourceProjectName>
<TestProjectName/>
</UnitTesting>
<ModelSupport>False</ModelSupport>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
Expand Down

0 comments on commit 1bbd436

Please sign in to comment.