type TSPdfSingletonKit = class public function Create(); class function Release(components: Components); class function GetComponent(components: Components; type: string); public hash_: array of tslobj; private static singleton_: Singleton; end; function TSPdfSingletonKit.Create(); begin hash_ := array(); end; class function TSPdfSingletonKit.Release(components: Components); begin singleton_.hash_[components] := nil; end; class function TSPdfSingletonKit.GetComponent(components: Components; type: string); begin if not ifObj(singleton_) then singleton_ := new TSPdfSingletonKit(); if ifnil(singleton_.hash_[components]) then singleton_.hash_[components] := array(); if ifObj(singleton_.hash_[components][type]) then return singleton_.hash_[components][type]; case type of "styles": begin styles := components.Styles; styles.Deserialize(); singleton_.hash_[components][type] := styles; return styles; end "styles_adapter": begin styles := class(TSPdfSingletonKit).GetComponent(components, "styles"); styles_adapter := new StylesAdapter(styles); singleton_.hash_[components][type] := styles_adapter; return styles_adapter; end "numbering_ware": begin numbering := components.Numbering; numbering_ware := nil; if ifObj(numbering) then begin numbering.Deserialize(); numbering_ware := new TSNumberingWare(numbering); end singleton_.hash_[components][type] := numbering_ware; return numbering_ware; end "document_rels_adapter": begin document_rels := components.DocumentRels; document_rels.Deserialize(); rels_adapter := new RelationShipsAdapter(document_rels); singleton_.hash_[components][type] := rels_adapter; return rels_adapter; end end; end;