Added Wizard support for MVCNameCaseDefault

This commit is contained in:
Daniele Teti 2024-06-09 23:53:25 +02:00
parent 6e07eb8b4f
commit 636ad27a83
6 changed files with 48 additions and 32 deletions

View File

@ -1001,7 +1001,7 @@ begin
.AppendLine() .AppendLine()
.AppendLine(' // MVCNameCaseDefault defines the name case of property names generated by the serializers.') .AppendLine(' // MVCNameCaseDefault defines the name case of property names generated by the serializers.')
.AppendLine(' // Possibile values are: ncAsIs, ncUpperCase, ncLowerCase (default), ncCamelCase, ncPascalCase, ncSnakeCase') .AppendLine(' // Possibile values are: ncAsIs, ncUpperCase, ncLowerCase (default), ncCamelCase, ncPascalCase, ncSnakeCase')
.AppendLine(' MVCNameCaseDefault := TMVCNameCase.ncLowerCase;') .AppendLine(' MVCNameCaseDefault := TMVCNameCase.' + Model.S[TConfigKey.serializer_name_case] + ';')
.AppendLine() .AppendLine()
.AppendLine(' // UseConsoleLogger defines if logs must be emitted to also the console (if available).') .AppendLine(' // UseConsoleLogger defines if logs must be emitted to also the console (if available).')
.AppendLine(' UseConsoleLogger := True;') .AppendLine(' UseConsoleLogger := True;')

View File

@ -74,6 +74,7 @@ type
jsonrpc_generate= 'jsonrpc.generate'; jsonrpc_generate= 'jsonrpc.generate';
jsonrpc_classname= 'jsonrpc.classname'; jsonrpc_classname= 'jsonrpc.classname';
jsonrpc_unit_name='jsonrpc.unit_name'; jsonrpc_unit_name='jsonrpc.unit_name';
serializer_name_case= 'serializer.name_case';
webmodule_classname= 'webmodule.classname'; webmodule_classname= 'webmodule.classname';
webmodule_unit_name= 'webmodule.unit_name'; webmodule_unit_name= 'webmodule.unit_name';
webmodule_middleware_analytics= 'webmodule.middleware.analytics'; webmodule_middleware_analytics= 'webmodule.middleware.analytics';

View File

@ -435,7 +435,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject
end end
object lblPATREON: TLabel object lblPATREON: TLabel
Left = 452 Left = 452
Top = 495 Top = 549
Width = 257 Width = 257
Height = 16 Height = 16
Cursor = crHandPoint Cursor = crHandPoint
@ -455,7 +455,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject
OnMouseLeave = lblPATREONMouseLeave OnMouseLeave = lblPATREONMouseLeave
end end
object btnOK: TButton object btnOK: TButton
Left = 549 Left = 561
Top = 580 Top = 580
Width = 77 Width = 77
Height = 27 Height = 27
@ -467,7 +467,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject
OnClick = btnOKClick OnClick = btnOKClick
end end
object btnCancel: TButton object btnCancel: TButton
Left = 632 Left = 644
Top = 580 Top = 580
Width = 77 Width = 77
Height = 27 Height = 27
@ -609,13 +609,13 @@ object frmDMVCNewProject: TfrmDMVCNewProject
object GroupBox1: TGroupBox object GroupBox1: TGroupBox
Left = 314 Left = 314
Top = 135 Top = 135
Width = 405 Width = 407
Height = 214 Height = 210
Caption = 'Middlewares' Caption = 'Middlewares'
TabOrder = 6 TabOrder = 6
DesignSize = ( DesignSize = (
405 407
214) 210)
object Label4: TLabel object Label4: TLabel
Left = 161 Left = 161
Top = 112 Top = 112
@ -647,7 +647,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject
TabOrder = 0 TabOrder = 0
end end
object chkCompression: TCheckBox object chkCompression: TCheckBox
Left = 27 Left = 28
Top = 24 Top = 24
Width = 153 Width = 153
Height = 17 Height = 17
@ -665,7 +665,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject
TabOrder = 2 TabOrder = 2
end end
object chkTrace: TCheckBox object chkTrace: TCheckBox
Left = 192 Left = 193
Top = 50 Top = 50
Width = 150 Width = 150
Height = 17 Height = 17
@ -675,7 +675,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject
TabOrder = 3 TabOrder = 3
end end
object chkCORS: TCheckBox object chkCORS: TCheckBox
Left = 192 Left = 193
Top = 24 Top = 24
Width = 135 Width = 135
Height = 17 Height = 17
@ -684,7 +684,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject
TabOrder = 4 TabOrder = 4
end end
object chkETAG: TCheckBox object chkETAG: TCheckBox
Left = 192 Left = 193
Top = 76 Top = 76
Width = 202 Width = 202
Height = 17 Height = 17
@ -704,7 +704,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject
object EdtFDConnDefFileName: TEdit object EdtFDConnDefFileName: TEdit
Left = 161 Left = 161
Top = 129 Top = 129
Width = 228 Width = 230
Height = 21 Height = 21
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
TabOrder = 7 TabOrder = 7
@ -713,7 +713,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject
object EdtConnDefName: TEdit object EdtConnDefName: TEdit
Left = 161 Left = 161
Top = 175 Top = 175
Width = 228 Width = 230
Height = 21 Height = 21
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
TabOrder = 8 TabOrder = 8
@ -722,14 +722,14 @@ object frmDMVCNewProject: TfrmDMVCNewProject
end end
object GroupBoxJSONRPC: TGroupBox object GroupBoxJSONRPC: TGroupBox
Left = 314 Left = 314
Top = 388 Top = 438
Width = 396 Width = 407
Height = 105 Height = 105
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
Caption = 'JSON-RPC 2.0' Caption = 'JSON-RPC end-point Options'
TabOrder = 7 TabOrder = 7
DesignSize = ( DesignSize = (
396 407
105) 105)
object Label3: TLabel object Label3: TLabel
Left = 16 Left = 16
@ -741,7 +741,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject
object EdtJSONRPCClassName: TEdit object EdtJSONRPCClassName: TEdit
Left = 16 Left = 16
Top = 72 Top = 72
Width = 365 Width = 376
Height = 21 Height = 21
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
TabOrder = 0 TabOrder = 0
@ -750,10 +750,10 @@ object frmDMVCNewProject: TfrmDMVCNewProject
object chkJSONRPC: TCheckBox object chkJSONRPC: TCheckBox
Left = 16 Left = 16
Top = 22 Top = 22
Width = 358 Width = 369
Height = 17 Height = 17
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Caption = 'Create JSONRPC 2.0 end-point' Caption = 'Create JSON-RPC 2.0 end-point'
Checked = True Checked = True
State = cbChecked State = cbChecked
TabOrder = 1 TabOrder = 1
@ -808,6 +808,23 @@ object frmDMVCNewProject: TfrmDMVCNewProject
State = cbChecked State = cbChecked
TabOrder = 12 TabOrder = 12
end end
object rgNameCase: TRadioGroup
Left = 314
Top = 351
Width = 407
Height = 81
Caption = 'Default style for serialized property names (MVCNameCaseDefault)'
Columns = 3
ItemIndex = 2
Items.Strings = (
'AsIs (as declared)'
'UpperCase (FOOBAR)'
'LowerCase (foobar)'
'CamelCase (fooBar)'
'PascalCase (FooBar)'
'SnakeCase (foo_bar)')
TabOrder = 13
end
object ApplicationEvents: TApplicationEvents object ApplicationEvents: TApplicationEvents
OnIdle = ApplicationEventsIdle OnIdle = ApplicationEventsIdle
Left = 264 Left = 264

View File

@ -50,7 +50,8 @@ uses
VCL.ExtCtrls, VCL.ExtCtrls,
System.Actions, System.Actions,
Vcl.ActnList, Vcl.ActnList,
Vcl.AppEvnts, JsonDataObjects; Vcl.AppEvnts,
JsonDataObjects;
type type
TfrmDMVCNewProject = class(TForm) TfrmDMVCNewProject = class(TForm)
@ -100,6 +101,7 @@ type
chkMustache: TCheckBox; chkMustache: TCheckBox;
chkServicesContainer: TCheckBox; chkServicesContainer: TCheckBox;
chkSqids: TCheckBox; chkSqids: TCheckBox;
rgNameCase: TRadioGroup;
procedure chkCreateControllerUnitClick(Sender: TObject); procedure chkCreateControllerUnitClick(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure Image1Click(Sender: TObject); procedure Image1Click(Sender: TObject);
@ -143,15 +145,13 @@ type
function GetConfigModel: TJSONObject; function GetConfigModel: TJSONObject;
end; end;
var
frmDMVCNewProject: TfrmDMVCNewProject;
implementation implementation
uses uses
MVCFramework.Commons, MVCFramework.Commons,
MVCFramework.Serializer.Commons,
System.StrUtils, System.StrUtils,
DMVC.Expert.Commons; DMVC.Expert.Commons, System.TypInfo;
{$R *.dfm} {$R *.dfm}
@ -357,7 +357,7 @@ begin
fModel.B[TConfigKey.jsonrpc_generate] := GetCreateJSONRPCInterface; fModel.B[TConfigKey.jsonrpc_generate] := GetCreateJSONRPCInterface;
fModel.S[TConfigKey.jsonrpc_classname] := GetJSONRPCClassName; fModel.S[TConfigKey.jsonrpc_classname] := GetJSONRPCClassName;
fModel.S[TConfigKey.jsonrpc_unit_name] := 'TBA'; fModel.S[TConfigKey.jsonrpc_unit_name] := 'TBA';
fModel.S[TConfigKey.serializer_name_case] := GetEnumName(TypeInfo(TMVCNameCase), rgNameCase.ItemIndex + 1);
//webmodule //webmodule
fModel.S[TConfigKey.webmodule_classname] := GetWebModuleClassName; fModel.S[TConfigKey.webmodule_classname] := GetWebModuleClassName;

View File

@ -44,7 +44,8 @@ uses
VCL.Controls, VCL.Controls,
VCL.Forms, VCL.Forms,
VCL.Dialogs, VCL.Dialogs,
VCL.StdCtrls, JsonDataObjects; VCL.StdCtrls,
JsonDataObjects;
type type
TfrmDMVCNewUnit = class(TForm) TfrmDMVCNewUnit = class(TForm)
@ -76,9 +77,6 @@ type
function GetConfigModel: TJSONObject; function GetConfigModel: TJSONObject;
end; end;
var
frmDMVCNewUnit: TfrmDMVCNewUnit;
implementation implementation
uses uses

View File

@ -60,7 +60,7 @@ type
TMVCSerializationType = (stUnknown, stDefault, stProperties, stFields); TMVCSerializationType = (stUnknown, stDefault, stProperties, stFields);
TMVCNameCase = (ncUseDefault, ncAsIs, ncUpperCase, ncLowerCase, ncCamelCase, ncPascalCase, ncSnakeCase); TMVCNameCase = (ncUseDefault {ncUseDefault must be the first item}, ncAsIs, ncUpperCase, ncLowerCase, ncCamelCase, ncPascalCase, ncSnakeCase);
TMVCDataType = (dtObject, dtArray); TMVCDataType = (dtObject, dtArray);