forked from Memnarch/Delphinus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDN.JSonFile.Uninstallation.pas
More file actions
86 lines (75 loc) · 2.34 KB
/
DN.JSonFile.Uninstallation.pas
File metadata and controls
86 lines (75 loc) · 2.34 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
#########################################################
# Copyright by Alexander Benikowski #
# This unit is part of the Delphinus project hosted on #
# https://github.com/Memnarch/Delphinus #
#########################################################
}
unit DN.JSonFile.Uninstallation;
interface
uses
DN.JSon,
DN.JSonFile;
type
TPackage = record
BPLFile: string;
DCPFile: string;
Installed: Boolean;
end;
TUninstallationFile = class(TJSonFile)
private
FPackages: TArray<TPackage>;
FSearchPathes: string;
FBrowsingPathes: string;
protected
procedure Load(const ARoot: TJSONObject); override;
procedure Save(const ARoot: TJSONObject); override;
public
property SearchPathes: string read FSearchPathes write FSearchPathes;
property BrowsingPathes: string read FBrowsingPathes write FBrowsingPathes;
property Packages: TArray<TPackage> read FPackages write FPackages;
end;
implementation
uses
SysUtils;
{ TUninstallation }
procedure TUninstallationFile.Load(const ARoot: TJSONObject);
var
LPackages: TJSONArray;
LPackage: TJSONObject;
i: Integer;
begin
inherited;
FSearchPathes := ReadString(ARoot, 'search_pathes');
FBrowsingPathes := ReadString(ARoot, 'browsing_pathes');
if ReadArray(ARoot, 'packages', LPackages) then
begin
SetLength(FPackages, LPackages.Count);
for i := 0 to Pred(LPackages.Count) do
begin
LPackage := LPackages.Items[i] as TJSONObject;
FPackages[i].BPLFile := ReadString(LPackage, 'bpl_file');
FPackages[i].DCPFile := ReadString(LPackage, 'dcp_file');
FPackages[i].Installed := ReadBoolean(LPackage, 'installed')
end;
end;
end;
procedure TUninstallationFile.Save(const ARoot: TJSONObject);
var
LPackages: TJSONArray;
LPackage: TPackage;
LJPackage: TJSONObject;
begin
inherited;
WritePath(ARoot, 'search_pathes', FSearchPathes);
WritePath(ARoot, 'browsing_pathes', FBrowsingPathes);
LPackages := WriteArray(ARoot, 'packages');
for LPackage in FPackages do
begin
LJPackage := WriteArrayObject(LPackages);
WritePath(LJPackage, 'bpl_file', LPackage.BPLFile);
WritePath(LJPackage, 'dcp_file', LPackage.DCPFile);
WriteBoolean(LJPackage, 'installed', LPackage.Installed);
end;
end;
end.