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
- ⚡ 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)
## What's New in dmvcframework-3.2.3-radium

View File

@ -312,14 +312,27 @@ resourcestring
' Config[TMVCConfigKey.ExposeServerSignature] := ''true'';' + sLineBreak +
' //Enable X-Powered-By Header in response' + 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 +
' Config[TMVCConfigKey.MaxRequestSize] := IntToStr(TMVCConstants.DEFAULT_MAX_REQUEST_SIZE);' + sLineBreak +
' end);' + sLineBreak +
' FMVC.AddController(%3:s);' + sLineBreak + sLineBreak +
' %4: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 +
sLineBreak +
'procedure %1:s.WebModuleDestroy(Sender: TObject);' + sLineBreak +

View File

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