-
Notifications
You must be signed in to change notification settings - Fork 64
/
DN.Package.pas
275 lines (237 loc) · 7.38 KB
/
DN.Package.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
{
#########################################################
# Copyright by Alexander Benikowski #
# This unit is part of the Delphinus project hosted on #
# https://github.com/Memnarch/Delphinus #
#########################################################
}
unit DN.Package;
interface
uses
Types,
Graphics,
Generics.Collections,
DN.Types,
DN.Package.Intf,
DN.Package.Version.Intf,
DN.Compiler.Intf;
type
TDNPackage = class(TInterfacedObject, IDNPackage)
private
FID: TGUID;
FCompilerMin: TCompilerVersion;
FCompilerMax: TCompilerVersion;
FName: string;
FAuthor: string;
FDescription: string;
FPicture: TPicture;
FDownloadLocation: string;
FLastUpdated: string;
FVersions: TList<IDNPackageVersion>;
FLicenses: TList<TDNLicense>;
FProjectUrl: string;
FHomepageUrl: string;
FReportUrl: string;
FPlatforms: TDNCompilerPlatforms;
function GetLicenseTypes: string;
protected
FLicenseTexts: TDictionary<string, string>;
function GetID: TGUID; virtual;
procedure SetID(const Value: TGUID); virtual;
function GetCompilerMax: TCompilerVersion; virtual;
function GetCompilerMin: TCompilerVersion; virtual;
procedure SetCompilerMax(const Value: TCompilerVersion); virtual;
procedure SetCompilerMin(const Value: TCompilerVersion); virtual;
function GetPlatforms: TDNCompilerPlatforms; virtual;
procedure SetPlatforms(const Value: TDNCompilerPlatforms); virtual;
function GetDownloadLocation: string; virtual;
procedure SetDownloadLocation(const Value: string); virtual;
function GetAuthor: string; virtual;
function GetDescription: string; virtual;
function GetName: string; virtual;
function GetPicture: TPicture; virtual;
procedure SetAuthor(const Value: string); virtual;
procedure SetDescription(const Value: string); virtual;
procedure SetName(const Value: string); virtual;
function GetLastUpdated: string; virtual;
procedure SetLastUpdated(const Value: string); virtual;
function GetVersions: TList<IDNPackageVersion>; virtual;
function GetLicense: TList<TDNLicense>; virtual;
function GetHomepageUrl: string; virtual;
function GetProjectUrl: string; virtual;
function GetReportUrl: string; virtual;
procedure SetProjectUrl(const Value: string); virtual;
procedure SetReportUrl(const Value: string); virtual;
procedure SetHomepageUrl(const Value: string); virtual;
function GetLicenseText(const ALicense: TDNLicense): string; virtual;
procedure SetLicenseText(const ALicense: TDNLicense; const Value: string); virtual;
public
constructor Create();
destructor Destroy(); override;
property ID: TGUID read GetID write SetID;
property CompilerMin: TCompilerVersion read GetCompilerMin write SetCompilerMin;
property CompilerMax: TCompilerVersion read GetCompilerMax write SetCompilerMax;
property Platforms: TDNCompilerPlatforms read GetPlatforms write SetPlatforms;
property Author: string read GetAuthor write SetAuthor;
property Name: string read GetName write SetName;
property Description: string read GetDescription write SetDescription;
property Picture: TPicture read GetPicture;
property DownloadLoaction: string read GetDownloadLocation write SetDownloadLocation;
property LastUpdated: string read GetLastUpdated write SetLastUpdated;
property Versions: TList<IDNPackageVersion> read GetVersions;
property Licenses: TList<TDNLicense> read GetLicense;
property LicenseText[const ALicense: TDNLicense]: string read GetLicenseText write SetLicenseText;
property LicenseTypes: string read GetLicenseTypes;
property ProjectUrl: string read GetProjectUrl write SetProjectUrl;
property HomepageUrl: string read GetHomepageUrl write SetHomepageUrl;
property ReportUrl: string read GetReportUrl write SetReportUrl;
end;
implementation
{ TDCPMPackage }
constructor TDNPackage.Create;
begin
inherited;
FPicture := TPicture.Create();
FVersions := TList<IDNPackageVersion>.Create();
FLicenses := TList<TDNLicense>.Create();
FLicenseTexts := TDictionary<string, string>.Create;
end;
destructor TDNPackage.Destroy;
begin
FVersions.Free;
FLicenses.Free;
FLicenseTexts.Free;
FPicture.Free;
inherited;
end;
function TDNPackage.GetAuthor: string;
begin
Result := FAuthor;
end;
function TDNPackage.GetCompilerMax: TCompilerVersion;
begin
Result := FCompilerMax;
end;
function TDNPackage.GetCompilerMin: TCompilerVersion;
begin
Result := FCompilerMin;
end;
function TDNPackage.GetDescription: string;
begin
Result := FDescription;
end;
function TDNPackage.GetDownloadLocation: string;
begin
Result := FDownloadLocation;
end;
function TDNPackage.GetHomepageUrl: string;
begin
Result := FHomepageUrl;
end;
function TDNPackage.GetID: TGUID;
begin
Result := FID;
end;
function TDNPackage.GetLastUpdated: string;
begin
Result := FLastUpdated;
end;
function TDNPackage.GetLicense: TList<TDNLicense>;
begin
Result := FLicenses;
end;
function TDNPackage.GetLicenseText(const ALicense: TDNLicense): string;
begin
if not FLicenseTexts.TryGetValue(ALicense.LicenseFile, Result) then
Result := '';
end;
function TDNPackage.GetLicenseTypes: string;
var
LLicense: TDNLicense;
begin
Result := '';
for LLicense in FLicenses do
begin
if Result <> '' then
Result := Result + ', ';
Result := Result + LLicense.LicenseType;
end;
end;
function TDNPackage.GetName: string;
begin
Result := FName;
end;
function TDNPackage.GetPicture: TPicture;
begin
Result := FPicture;
end;
function TDNPackage.GetPlatforms: TDNCompilerPlatforms;
begin
Result := FPlatforms;
end;
function TDNPackage.GetProjectUrl: string;
begin
Result := FProjectUrl;
end;
function TDNPackage.GetReportUrl: string;
begin
Result := FReportUrl;
end;
function TDNPackage.GetVersions: TList<IDNPackageVersion>;
begin
Result := FVersions;
end;
procedure TDNPackage.SetAuthor(const Value: string);
begin
FAuthor := Value;
end;
procedure TDNPackage.SetCompilerMax(const Value: TCompilerVersion);
begin
FCompilerMax := Value;
end;
procedure TDNPackage.SetCompilerMin(const Value: TCompilerVersion);
begin
FCompilerMin := Value;
end;
procedure TDNPackage.SetDescription(const Value: string);
begin
FDescription := Value;
end;
procedure TDNPackage.SetDownloadLocation(const Value: string);
begin
FDownloadLocation := Value;
end;
procedure TDNPackage.SetHomepageUrl(const Value: string);
begin
FHomepageUrl := Value;
end;
procedure TDNPackage.SetID(const Value: TGUID);
begin
FID := Value;
end;
procedure TDNPackage.SetLastUpdated(const Value: string);
begin
FLastUpdated := Value;
end;
procedure TDNPackage.SetLicenseText(const ALicense: TDNLicense;
const Value: string);
begin
FLicenseTexts.AddOrSetValue(ALicense.LicenseFile, Value);
end;
procedure TDNPackage.SetName(const Value: string);
begin
FName := Value;
end;
procedure TDNPackage.SetPlatforms(const Value: TDNCompilerPlatforms);
begin
FPlatforms := Value;
end;
procedure TDNPackage.SetProjectUrl(const Value: string);
begin
FProjectUrl := Value;
end;
procedure TDNPackage.SetReportUrl(const Value: string);
begin
FReportUrl := Value;
end;
end.