| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | unit ProjGatherProperties;interfaceuses  Classes, ZhAPI;type  TProjGatherProperty = class  private    FName: string;    FValue: string;  public    constructor Create(const AName: string);    destructor Destroy; override;    property Name: string read FName write FName;    property Value: string read FValue write FValue;  end;  TProjGatherProperties = class  private    FList: TList;    function FindProjGatherProperty(const AName: string): TProjGatherProperty;    function AddProjGatherProperty(const AName: string): TProjGatherProperty;    function GetCount: Integer;    function GetPgPropperty(AIndex: Integer): TProjGatherProperty;  public    constructor Create;    destructor Destroy; override;    function GetProjGatherProperty(const AName: string): TProjGatherProperty;    property Count: Integer read GetCount;    property PgProperty[AIndex: Integer]: TProjGatherProperty read GetPgPropperty;  end;implementationuses SysUtils;{ TProjGatherProperty }constructor TProjGatherProperty.Create(const AName: string);begin  FName := AName;end;destructor TProjGatherProperty.Destroy;begin  inherited;end;{ TProjGatherProperties }function TProjGatherProperties.AddProjGatherProperty(  const AName: string): TProjGatherProperty;begin  Result := TProjGatherProperty.Create(AName);  FList.Add(Result);end;constructor TProjGatherProperties.Create;begin  FList := TList.Create;end;destructor TProjGatherProperties.Destroy;begin  ClearObjects(FList);  FList.Free;  inherited;end;function TProjGatherProperties.FindProjGatherProperty(  const AName: string): TProjGatherProperty;var  i: Integer;  vProperty: TProjGatherProperty;begin  Result := nil;  for i := 0 to Count - 1 do  begin    vProperty := PgProperty[i];    if vProperty.Name = AName then    begin      Result := vProperty;      Break;    end;  end;end;function TProjGatherProperties.GetCount: Integer;begin  Result := FList.Count;end;function TProjGatherProperties.GetPgPropperty(  AIndex: Integer): TProjGatherProperty;begin  Result := TProjGatherProperty(FList.Items[AIndex]);end;function TProjGatherProperties.GetProjGatherProperty(  const AName: string): TProjGatherProperty;begin  Result := FindProjGatherProperty(AName);  if not Assigned(Result) then    Result := AddProjGatherProperty(AName);end;end.
 |