Repository navigation
Expand file tree
/
Copy pathDN.JSonFile.Info.pas
More file actions
99 lines (90 loc) · 3.05 KB
/
Copy pathDN.JSonFile.Info.pas
File metadata and controls
99 lines (90 loc) · 3.05 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
87
88
89
90
91
92
93
94
95
96
97
98
99
{
#########################################################
# Copyright by Alexander Benikowski #
# This unit is part of the Delphinus project hosted on #
# https://github.com/Memnarch/Delphinus #
#########################################################
}
unit DN.JSonFile.Info;
interface
uses
Classes,
Types,
SysUtils,
DN.Types,
DN.JSon,
DN.JSonFile;
type
TInfoFile = class(TJSonFile)
private
FID: TGUID;
FPicture: string;
FFirstVersion: string;
FPackageCompilerMax: TCompilerVersion;
FPackageCompilerMin: TCompilerVersion;
FCompilerMin: TCompilerVersion;
FCompilerMax: TCompilerVersion;
FName: string;
FLicenseFile: string;
FLicenseType: string;
protected
procedure Load(const ARoot: TJSONObject); override;
procedure Save(const ARoot: TJSONObject); override;
function ReadID(const AObject: TJSONObject): TGUID;
public
property Picture: string read FPicture;
property ID: TGUID read FID write FID;
property Name: string read FName write FName;
property LicenseType: string read FLicenseType write FLicenseType;
property LicenseFile: string read FLicenseFile write FLicenseFile;
property FirstVersion: string read FFirstVersion;
property PackageCompilerMin: TCompilerVersion read FPackageCompilerMin;
property PackageCompilerMax: TCompilerVersion read FPackageCompilerMax;
property CompilerMin: TCompilerVersion read FCompilerMin;
property CompilerMax: TCompilerVersion read FCompilerMax;
end;
implementation
{ TInfoFile }
procedure TInfoFile.Load(const ARoot: TJSONObject);
begin
inherited;
FPicture := ReadString(ARoot, 'picture');
FID := ReadID(ARoot);
FName := ReadString(ARoot, 'name');
FLicenseType := ReadString(ARoot, 'license_type');
FLicenseFile := ReadString(ARoot, 'license_file');
FFirstVersion := ReadString(ARoot, 'first_version');
FPackageCompilerMax := ReadFloat(ARoot, 'package_compiler_max');
FPackageCompilerMin := ReadFloat(ARoot, 'package_compiler_min');
FCompilerMin := ReadFloat(ARoot, 'compiler_min');
FCompilerMax := ReadFloat(ARoot, 'compiler_max');
end;
function TInfoFile.ReadID(const AObject: TJSONObject): TGUID;
var
LID: string;
begin
LID := ReadString(AObject, 'id');
try
if LID <> '' then
Result := StringToGUID(LID)
else
Result := TGUID.Empty;
except
Result := TGUID.Empty;
end;
end;
procedure TInfoFile.Save(const ARoot: TJSONObject);
begin
inherited;
WritePath(ARoot, 'picture', FPicture);
WriteString(ARoot, 'id', FID.ToString);
WriteString(ARoot, 'name', FName);
WriteString(ARoot, 'license_type', FLicenseType);
WritePath(ARoot, 'license_file', FLicenseFile);
WriteString(ARoot, 'first_version', FFirstVersion);
WriteFloat(ARoot, 'package_compiler_max', FPackageCompilerMax);
WriteFloat(ARoot, 'package_compiler_min', FPackageCompilerMin);
WriteFloat(ARoot, 'compiler_min', FCompilerMin);
WriteFloat(ARoot, 'compiler_max', FCompilerMax);
end;
end.