forked from Memnarch/Delphinus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDN.JSonFile.InstalledInfo.pas
61 lines (53 loc) · 1.83 KB
/
DN.JSonFile.InstalledInfo.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
52
53
54
55
56
57
58
59
60
61
{
#########################################################
# Copyright by Alexander Benikowski #
# This unit is part of the Delphinus project hosted on #
# https://github.com/Memnarch/Delphinus #
#########################################################
}
unit DN.JSonFile.InstalledInfo;
interface
uses
DN.Version,
DN.JSon,
DN.JSonFile.Info;
type
TInstalledInfoFile = class(TInfoFile)
private
FDescription: string;
FVersion: TDNVersion;
FAuthor: string;
FProjectUrl: string;
FHomepageUrl: string;
protected
procedure Load(const ARoot: TJSONObject); override;
procedure Save(const ARoot: TJSONObject); override;
public
property Author: string read FAuthor write FAuthor;
property Description: string read FDescription write FDescription;
property Version: TDNVersion read FVersion write FVersion;
property ProjectUrl: string read FProjectUrl write FProjectUrl;
property HomepageUrl: string read FHomepageUrl write FHomepageUrl;
end;
implementation
{ TInstalledInfoFile }
procedure TInstalledInfoFile.Load(const ARoot: TJSONObject);
begin
inherited;
FAuthor := ReadString(ARoot, 'author');
FDescription := ReadString(ARoot, 'description');
if not TDNVersion.TryParse(ReadString(ARoot, 'version'), FVersion) then
FVersion := TDNVersion.Create();
FProjectUrl := ReadString(ARoot, 'project_url');
FHomepageUrl := ReadString(ARoot, 'homepage_url');
end;
procedure TInstalledInfoFile.Save(const ARoot: TJSONObject);
begin
inherited;
WriteString(ARoot, 'author', FAuthor);
WriteString(ARoot, 'description', FDescription);
WriteString(ARoot, 'version', FVersion.ToString);
WriteString(ARoot, 'project_url', FProjectUrl);
WriteString(ARoot, 'homepage_url', FHomepageUrl);
end;
end.