-
Notifications
You must be signed in to change notification settings - Fork 10
/
DW.VCL.ScriptParams.pas
51 lines (42 loc) · 1007 Bytes
/
DW.VCL.ScriptParams.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
unit DW.VCL.ScriptParams;
interface
uses Classes, DW.JSON.JsonData;
type
TDWScriptParams = class(TStringList)
private
function GetJson(const Name: string): TJsonObject;
procedure SetJson(const Name: string; const Value: TJsonObject);
public
constructor Create;
property JSON[const Name: string]: TJsonObject read GetJson write SetJson;
end;
implementation
constructor TDWScriptParams.Create;
begin
inherited;
Duplicates := dupError;
OwnsObjects := True;
end;
function TDWScriptParams.GetJson(const Name: string): TJsonObject;
var
i: integer;
begin
i := IndexOf(Name);
if i < 0 then
begin
Result := TJsonObject.Create;
AddObject(Name, Result);
end
else if Objects[i] = nil then
begin
Result := TJsonObject.Create;
Objects[i] := Result;
end
else
Result := TJsonObject(Objects[i]);
end;
procedure TDWScriptParams.SetJson(const Name: string; const Value: TJsonObject);
begin
JSON[Name].Assign(Value);
end;
end.