Ignore:
Timestamp:
Sep 9, 2022, 8:20:25 PM (21 months ago)
Author:
chronos
Message:
  • Modified: Removed TemplateGenerics package. Generics usage replaced by standard Generics.Collections.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/CoolWeb/Common/UXmlClasses.pas

    r137 r138  
    44
    55uses
    6   Classes, SysUtils, StrUtils, SpecializedList, SpecializedDictionary;
     6  Classes, SysUtils, StrUtils, Generics.Collections, UGenerics;
    77
    88type
     
    1212  public
    1313    property AsString: string read GetAsString;
     14  end;
     15
     16  TXmlTag = class;
     17  TXmlString = class;
     18
     19  { TXmlElements }
     20
     21  TXmlElements = class(TObjectList<TXmlElement>)
     22    function AddTag(Name: string): TXmlTag;
     23    function AddString(Text: string): TXmlString;
    1424  end;
    1525
     
    2939    Name: string;
    3040    Attributes: TDictionaryStringString;
    31     SubElements: TListObject; // TListObject<TXmlElement>;
     41    SubElements: TXmlElements;
    3242    constructor Create;
    3343    destructor Destroy; override;
     
    5262implementation
    5363
     64{ TXmlElements }
     65
     66function TXmlElements.AddTag(Name: string): TXmlTag;
     67begin
     68  Result := TXmlTag.Create;
     69  Result.Name := Name;
     70  Add(Result);
     71end;
     72
     73function TXmlElements.AddString(Text: string): TXmlString;
     74begin
     75  Result := TXmlString.Create;
     76  Result.Text := Text;
     77  Add(Result);
     78end;
     79
    5480{ THtmlElement }
    5581
     
    5884  ShringEmpty := True;
    5985  Attributes := TDictionaryStringString.Create;
    60   SubElements := TListObject.Create;
     86  SubElements := TXmlElements.Create;
    6187  EndTagSymbol := '/';
    6288end;
     
    6490destructor TXmlTag.Destroy;
    6591begin
    66   Attributes.Free;
    67   SubElements.Free;
     92  FreeAndNil(Attributes);
     93  FreeAndNil(SubElements);
    6894  inherited;
    6995end;
     
    74100  I: Integer;
    75101  Content: string;
     102  Attribute: TPair<string, string>;
    76103begin
    77104  Content := '';
     
    80107
    81108  AttributesText := '';
    82   for I := 0 to Attributes.Count - 1 do
    83     AttributesText := AttributesText + ' ' + Attributes.Keys[I] + '="' + Attributes[I].Value + '"';
     109  for Attribute in Attributes do
     110    AttributesText := AttributesText + ' ' + Attribute.Key + '="' + Attribute.Value + '"';
    84111
    85112  if Name <> '' then begin
     
    123150destructor TXmlDocument.Destroy;
    124151begin
    125   Content.Free;
    126   MainTag.Free;
     152  FreeAndNil(Content);
     153  FreeAndNil(MainTag);
    127154  inherited;
    128155end;
Note: See TracChangeset for help on using the changeset viewer.