| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 | unit StandardLibs;interfaceuses Classes, StandardLib, ZhAPI, ConfigDoc;type  TStandardLibs = class  private    FConfigInfo: TConfigInfo;    FLibs: TList;    function GetStandardGclLib: TStandardLib;    function GetStandardXmLib: TStandardLib;    function FindLib(const AFileName: string): TStandardLib;    function CreateLib(const AFileName: string): TStandardLib;    procedure ClearLibs;    procedure OpenDefaultStandardLibs;  public    constructor Create(AConfigInfo: TConfigInfo);    destructor Destroy; override;    function GetLib(const AFileName: string): TStandardLib;    property StandardXmLib: TStandardLib read GetStandardXmLib;    property StandardGclLib: TStandardLib read GetStandardGclLib;  end;implementation{ TStandardLibs }procedure TStandardLibs.ClearLibs;begin  ClearObjects(FLibs);end;constructor TStandardLibs.Create(AConfigInfo: TConfigInfo);begin  FConfigInfo := AConfigInfo;  FLibs := TList.Create;  OpenDefaultStandardLibs;end;function TStandardLibs.CreateLib(const AFileName: string): TStandardLib;begin  Result := TStandardLib.Create;  Result.Open(AFileName);  FLibs.Add(Result);end;destructor TStandardLibs.Destroy;begin  ClearLibs;  FLibs.Free;  inherited;end;function TStandardLibs.FindLib(const AFileName: string): TStandardLib;var  I: Integer;begin  for I := 0 to FLibs.Count - 1 do  begin    Result := TStandardLib(FLibs.List^[I]);    if Result.FileName = AFileName then      Exit;  end;  Result := nil;end;function TStandardLibs.GetLib(const AFileName: string): TStandardLib;begin  Result := FindLib(AFileName);  if Result = nil then    Result := CreateLib(AFileName);end;function TStandardLibs.GetStandardGclLib: TStandardLib;begin  Result := GetLib(FConfigInfo.StandardGclLib);end;function TStandardLibs.GetStandardXmLib: TStandardLib;begin  Result := GetLib(FConfigInfo.StandardXmLib);end;procedure TStandardLibs.OpenDefaultStandardLibs;begin  GetLib(FConfigInfo.StandardXmLib);  GetLib(FConfigInfo.StandardGclLib);end;end.
 |