Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- TGenericStringList<T: Class> = class(TStringList)
- private
- function GetObject(Index: Integer): T; reintroduce;
- procedure PutObject(Index: Integer; const Value: T); reintroduce;
- public
- function AddObject(const S: string; AObject: T): Integer; reintroduce;
- function IndexOfObject(AObject: T): Integer; reintroduce;
- procedure InsertObject(Index: Integer; const S: string; AObject: T);
- reintroduce;
- function ToObjectArray: TArray<T>; reintroduce;
- property Objects[Index: Integer]: T read GetObject write PutObject;
- end;
- { TGenericStringList<T> }
- function TGenericStringList<T>.AddObject(const S: string; AObject: T): Integer;
- begin
- Result := inherited AddObject(S, AObject);
- end;
- function TGenericStringList<T>.GetObject(Index: Integer): T;
- begin
- Result := inherited GetObject(Index) as T;
- end;
- function TGenericStringList<T>.IndexOfObject(AObject: T): Integer;
- begin
- Result := inherited IndexOfObject(AObject);
- end;
- procedure TGenericStringList<T>.InsertObject(Index: Integer; const S: string;
- AObject: T);
- begin
- inherited InsertObject(Index, S, AObject);
- end;
- procedure TGenericStringList<T>.PutObject(Index: Integer; const Value: T);
- begin
- inherited PutObject(Index, Value);
- end;
- function TGenericStringList<T>.ToObjectArray: TArray<T>;
- begin
- Result := TArray<T>(inherited ToObjectArray);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement