Skip to content

Commit

Permalink
https://github.com/danieleteti/delphimvcframework/issues/378
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed May 6, 2020
1 parent 4cd30b5 commit a1c6d82
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ Congratulations to Daniele Teti and all the staff for the excellent work!" -- Ma

> We started the process of migrating our systems to micro services and are loving the DMVCFramework "DMVCFramework is definitely part of our lives right now". -- E. Costa
> "Thank you for the great framework! We are very happy with this!" -- Andreas
## DMVCFramework Main Features

* Simple to use, check the ["Getting Started: 5 minutes guide"](https://danieleteti.gitbooks.io/delphimvcframework/content/chapter_getting_started.html) and you will be up and running in 5 minutes or less! (the guide is a bit outdated - a new book is being written by Daniele Teti. Let us know if you are interested in [DMVCFramework Handbook](https://leanpub.com/delphimvcframework))
* Simple to use, check the ["Getting Started: 5 minutes guide"](https://danieleteti.gitbooks.io/delphimvcframework/content/chapter_getting_started.html) (it is quite old) and you will be up and running in 5 minutes or less! (the guide is a bit outdated - a new book is being written by Daniele Teti. Let us know if you are interested in [DMVCFramework Handbook](https://leanpub.com/delphimvcframework))
* [Project Roadmap](roadmap.md) is always public
* More than 40 samples to learn all the features and be proficient and productive
* Commercially supported by [bit Time Professionals](http://www.bittimeprofessionals.it) (training, consultancy, custom development etc.)
Expand All @@ -61,7 +63,7 @@ Congratulations to Daniele Teti and all the staff for the excellent work!" -- Ma
* Integrated REST Client
* Works with Delphi 10 Seattle, Delphi 10.1 Berlin, Delphi 10.2 Tokyo, Delphi 10.3 Rio
* Works on Linux (Delphi 10.2 Tokyo or better)
* Completely unit tested (more than 130 unit tests)
* Completely unit tested (more than 170 unit tests)
* There is a sample for each functionality (check the [dmvcframework_(yourversion)_samples.zip](https://github.com/danieleteti/delphimvcframework/releases))
* Server side generated pages using [Mustache for Delphi](https://github.com/synopse/dmustache) or [TemplatePro](https://github.com/danieleteti/templatepro)
* Specific trainings are available (email to `professionals@bittime.it` for a date and a place)
Expand Down Expand Up @@ -459,6 +461,13 @@ end;

Before it was not possible because you should add the `MVCListOf` attribute to the `TObjectList` type property.

- New! Added serialization support for (thanks to [dockerandy](https://github.com/dockerandy) for his initial work)

- `TArray<String>`
- `TArray<Integer>`
- `TArray<Int64>`
- `TArray<Double>`

- New! The **MVCAREntitiesGenerator** can optionally register all the generated entities also in the `ActiveRecordMappingRegistry` (Thanks to [Fabrizio Bitti](https://twitter.com/fabriziobitti) from [bit Time Software](http://www.bittime.it))

- New! Children objects lifecycle management in `TMVCActiveRecord` (methods `AddChildren` and `RemoveChildren`). Really useful to manage child objects such relations or derived properties and are safe in case of multiple addition of the same object as children.
Expand Down
13 changes: 13 additions & 0 deletions samples/commons/BusinessObjectsU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ TPerson = class
class function GetList(const aCount: Integer = 3): TObjectList<TPerson>;
end;

TClassWithArrays = class
private
fArrayOfString: TArray<string>;
fArrayOfInt: TArray<Integer>;
fArrayOfInt64: TArray<Int64>;
fArrayOfDouble: TArray<Double>;
public
property ArrayOfString: TArray<string> read fArrayOfString write fArrayOfString;
property ArrayOfInt: TArray<Integer> read fArrayOfInt write fArrayOfInt;
property ArrayOfInt64: TArray<Int64> read fArrayOfInt64 write fArrayOfInt64;
property ArrayOfDouble: TArray<Double> read fArrayOfDouble write fArrayOfDouble;
end;

[MVCNameCase(ncLowerCase)]
[MVCNameCase(ncLowerCase)]
[MVCTable('nullables_test')]
Expand Down
16 changes: 16 additions & 0 deletions samples/renders/RenderSampleControllerU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ TRenderSampleController = class(TMVCController)
[MVCPath('/nullables/many')]
procedure GetManyNullableObjects;

// Arrays
[MVCHTTPMethod([httpGET])]
[MVCPath('/arrays')]
procedure GetClassWithArrays;
end;

implementation
Expand Down Expand Up @@ -323,6 +327,18 @@ procedure TRenderSampleController.GetBinaryData(const filename: string);
Render(TFileStream.Create(lFullFilePath, fmOpenRead or fmShareDenyNone));
end;

procedure TRenderSampleController.GetClassWithArrays;
var
lClass: TClassWithArrays;
begin
lClass := TClassWithArrays.Create;
lClass.ArrayOfString := ['one', 'two', 'three'];
lClass.ArrayOfInt := [1, 2, 3];
lClass.ArrayOfInt64 := [high(Int64), high(Int64) - 1, high(Int64) - 2];
lClass.ArrayOfDouble := [1234.5678, 2345.6789, 3456.78901];
Render(lClass);
end;

procedure TRenderSampleController.GetCustomerByID_AsTObject(const ID: Integer);
var
Cust: TCustomer;
Expand Down
16 changes: 14 additions & 2 deletions sources/MVCFramework.Serializer.JsonDataObjects.pas
Original file line number Diff line number Diff line change
Expand Up @@ -832,19 +832,31 @@ function TMVCJsonDataObjectsSerializer.JsonArrayToArray(const AJsonArray: TJDOJs
I: Integer;
lStrArr: TArray<string>;
lIntArr: TArray<Integer>;
lLongArr: TArray<Int64>;
lDoubleArr: TArray<Double>;
begin
for I := 0 to Pred(AJsonArray.Count) do
begin
case AJsonArray.types[0] of
jdtString:
lStrArr := lStrArr + [AJsonArray.Items[I].Value];
jdtInt:
lIntArr := lIntArr + [AJsonArray.Items[I].Value.ToInteger];
lIntArr := lIntArr + [AJsonArray.Items[I].IntValue];
jdtLong:
lLongArr := lLongArr + [AJsonArray.Items[I].LongValue];
jdtFloat:
lDoubleArr := lDoubleArr + [AJsonArray.Items[I].FloatValue];
end;
end;

if Length(lStrArr) > 0 then
Result := TValue.From < TArray < string >> (lStrArr)
else if Length(lIntArr) > 0 then
Result := TValue.From < TArray < Integer >> (lIntArr)
else if Length(lLongArr) > 0 then
Result := TValue.From < TArray < Int64 >> (lLongArr)
else
Result := TValue.From < TArray < Integer >> (lIntArr);
Result := TValue.From < TArray < Double >> (lDoubleArr);
end;

procedure TMVCJsonDataObjectsSerializer.JsonArrayToDataSet(const AJsonArray: TJDOJsonArray; const ADataSet: TDataSet;
Expand Down

0 comments on commit a1c6d82

Please sign in to comment.