{
很早就写了. 只针对delphixe 以上的版本可用.
希望不是自己在造*.
}
1 unit U_ClassUtility;
interface
uses generics.defaults,DateUtils,Classes,SysUtils,Windows, generics.collections;
type
TGenericList<T> = class
private
fList : Tlist<T>;
procedure SetList(const Value: TList<T>);
public
procedure clear;
procedure Add(Aobj : T);
constructor Create;
destructor Destroy; override;
property List : TList<T> read FList write SetList;
end;
implementation
{ TGenericList<T> }
procedure TGenericList<T>.Add(Aobj: T);
begin
fList.Add(Aobj);
end;
procedure TGenericList<T>.clear;
var
i : Integer;
begin
for I := to fList.Count - do
TObject(fList.Items[i]).Free;
fList.Clear;
end;
constructor TGenericList<T>.Create;
begin
fList := TList<T>.Create;
end;
destructor TGenericList<T>.Destroy;
begin
clear;
fList.Free;
inherited;
end;
procedure TGenericList<T>.SetList(const Value: TList<T>);
begin
FList := Value;
end;
end.