Improved Wizard (commeneted code to show how to use context events)

This commit is contained in:
Daniele Teti 2023-03-24 17:52:32 +01:00
parent 886f8b8f9b
commit 487cf8ec8b
3 changed files with 25 additions and 7 deletions

View File

@ -218,6 +218,8 @@ Congratulations to Daniele Teti and all the staff for the excellent work!" -- Ma
- ⚡ Support for Delphi 11.3 Alexandria - ⚡ Support for Delphi 11.3 Alexandria
- ⚡ Ability to use records in swagger param and response attributes [Issue 649](https://github.com/danieleteti/delphimvcframework/issues/649) - ⚡ Ability to use records in swagger param and response attributes [Issue 649](https://github.com/danieleteti/delphimvcframework/issues/649)
- ⚡ Improved Wizard - now it produces commented code to show how to use `ContextEvents`
- ⚡ Improved compatibility with Delphi 10.2 Tokyo and older versions (Thanks Mark Lobanov)
- 🐞 FIX [Issue 648](https://github.com/danieleteti/delphimvcframework/issues/648) Thanks to [sf-spb](https://github.com/sf-spb) - 🐞 FIX [Issue 648](https://github.com/danieleteti/delphimvcframework/issues/648) Thanks to [sf-spb](https://github.com/sf-spb)
## What's New in dmvcframework-3.2.3-radium ## What's New in dmvcframework-3.2.3-radium

View File

@ -312,14 +312,27 @@ resourcestring
' Config[TMVCConfigKey.ExposeServerSignature] := ''true'';' + sLineBreak + ' Config[TMVCConfigKey.ExposeServerSignature] := ''true'';' + sLineBreak +
' //Enable X-Powered-By Header in response' + sLineBreak + ' //Enable X-Powered-By Header in response' + sLineBreak +
' Config[TMVCConfigKey.ExposeXPoweredBy] := ''true'';' + sLineBreak + ' Config[TMVCConfigKey.ExposeXPoweredBy] := ''true'';' + sLineBreak +
// ' // Define a default URL for requests that don''t map to a route or a file (useful for client side web app)' + sLineBreak +
// ' Config[TMVCConfigKey.FallbackResource] := ''index.html'';' + sLineBreak +
' // Max request size in bytes' + sLineBreak + ' // Max request size in bytes' + sLineBreak +
' Config[TMVCConfigKey.MaxRequestSize] := IntToStr(TMVCConstants.DEFAULT_MAX_REQUEST_SIZE);' + sLineBreak + ' Config[TMVCConfigKey.MaxRequestSize] := IntToStr(TMVCConstants.DEFAULT_MAX_REQUEST_SIZE);' + sLineBreak +
' end);' + sLineBreak + ' end);' + sLineBreak +
' FMVC.AddController(%3:s);' + sLineBreak + sLineBreak + ' FMVC.AddController(%3:s);' + sLineBreak + sLineBreak +
' %4:s ' + sLineBreak + ' %4:s ' + sLineBreak +
' %5:s ' + sLineBreak + ' %5:s ' + sLineBreak +
' ' + sLineBreak +
' {' + sLineBreak +
' FMVC.OnWebContextCreate( ' + sLineBreak +
' procedure(const Context: TWebContext) ' + sLineBreak +
' begin ' + sLineBreak +
' // Initialize services to make them accessibile from Context ' + sLineBreak +
' // Context.CustomIntfObject := TMyService.Create; ' + sLineBreak +
' end); ' + sLineBreak +
' ' + sLineBreak +
' FMVC.OnWebContextDestroy(' + sLineBreak +
' procedure(const Context: TWebContext)' + sLineBreak +
' begin' + sLineBreak +
' //Cleanup services, if needed' + sLineBreak +
' end);' + sLineBreak +
' }' + sLineBreak +
'end;' + sLineBreak + 'end;' + sLineBreak +
sLineBreak + sLineBreak +
'procedure %1:s.WebModuleDestroy(Sender: TObject);' + sLineBreak + 'procedure %1:s.WebModuleDestroy(Sender: TObject);' + sLineBreak +

View File

@ -347,8 +347,10 @@ uses
Json.Schema.Field.Booleans; Json.Schema.Field.Booleans;
function GetRecordType(const aQualifiedName: String): TRttiType; function GetRecordType(const aQualifiedName: String): TRttiType;
var
lContext: TRttiContext;
begin begin
var lContext := TRttiContext.Create; lContext := TRttiContext.Create;
try try
result := lContext.FindType(aQualifiedName); result := lContext.FindType(aQualifiedName);
finally finally
@ -705,7 +707,6 @@ var
lEnumMappedValues: TList<string>; lEnumMappedValues: TList<string>;
I: Integer; I: Integer;
begin begin
var lContext := TRttiContext.Create;
for lField in aRttiType.GetFields do for lField in aRttiType.GetFields do
begin begin
lSkipProp := False; lSkipProp := False;
@ -823,7 +824,9 @@ begin
lJsonField.Required := lFieldSchemaDef.Required; lJsonField.Required := lFieldSchemaDef.Required;
lJsonField.Nullable := lFieldSchemaDef.Nullable; lJsonField.Nullable := lFieldSchemaDef.Nullable;
if not lFieldSchemaDef.Description.IsEmpty then if not lFieldSchemaDef.Description.IsEmpty then
begin
TJsonFieldInteger(lJsonField).Description := lFieldSchemaDef.Description; TJsonFieldInteger(lJsonField).Description := lFieldSchemaDef.Description;
end;
aJsonFieldRoot.AddField(lJsonField); aJsonFieldRoot.AddField(lJsonField);
end; end;