-
Notifications
You must be signed in to change notification settings - Fork 5
/
IdSoapWsdlUtils.pas
94 lines (81 loc) · 2.45 KB
/
IdSoapWsdlUtils.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
unit IdSoapWsdlUtils;
interface
uses
Classes,
IdSoapClasses,
IdSoapDebug,
IdSoapITI,
IdSoapWSDL;
type
TIdSoapWSDLCategoryList = class (TIdBaseObject)
private
FSubList : TStringList;
FIntfList : TStringList;
public
constructor create;
destructor Destroy; override;
procedure Add(ACategory : String; AInterface : TIdSoapITIInterface);
function AsHTML(APrefix : String) : String;
end;
implementation
uses
IdSoapConsts,
IdSoapUtilities,
SysUtils;
const
ASSERT_UNIT = 'IdSoapWsdlUtils';
{ TIdSoapWSDLCategoryList }
constructor TIdSoapWSDLCategoryList.create;
begin
inherited;
FSubList := TIdStringList.create(true);
FIntfList := TIdStringList.create(false);
end;
destructor TIdSoapWSDLCategoryList.destroy;
begin
FreeAndNil(FSubList);
FreeAndNil(FIntfList);
inherited;
end;
procedure TIdSoapWSDLCategoryList.Add(ACategory : String; AInterface: TIdSoapITIInterface);
const ASSERT_LOCATION = ASSERT_UNIT+'.TIdSoapWSDLCategoryList.Add';
var
s1, s2 : String;
i : integer;
begin
assert(Self.TestValid(TIdSoapWSDLCategoryList), ASSERT_LOCATION+': Self is not valid');
assert(AInterface.TestValid(TIdSoapITIInterface), ASSERT_LOCATION+': Interface is not valid');
if ACategory = '' then
begin
FIntfList.AddObject(AInterface.Name, AInterface);
end
else
begin
SplitString(ACategory, '\', s1, s2);
i := FSubList.IndexOf(s1);
if i = -1 then
begin
i := FSubList.AddObject(s1, TIdSoapWSDLCategoryList.create);
end;
(FSubList.Objects[i] as TIdSoapWSDLCategoryList).Add(s2, AInterface);
end;
end;
function TIdSoapWSDLCategoryList.AsHTML(APrefix : String): String;
const ASSERT_LOCATION = ASSERT_UNIT+'.TIdSoapWSDLCategoryList.AsHTML';
var
i : integer;
LIntf : TIdSoapITIInterface;
begin
assert(Self.TestValid(TIdSoapWSDLCategoryList), ASSERT_LOCATION+': Self is not valid');
result := '';
for i := 0 to FSubList.Count - 1 do
begin
result := result + '<h4>'+FSubList[i]+'</h4><blockquote>'+(FSubList.objects[i] as TIdSoapWSDLCategoryList).AsHTML(APrefix)+'<br></blockquote>'+EOL_PLATFORM;
end;
for i := 0 to FIntfList.Count - 1 do
begin
LIntf := FIntfList.Objects[i] as TIdSoapITIInterface;
result := result + '<a href="'+APrefix+LIntf.Name+'">'+LIntf.Name+'</a> <font size="-1">'+LIntf.Documentation+'</font><br>'+EOL_PLATFORM;
end;
end;
end.