English 中文(简体)
在德尔菲斯,将目标主义的祖先转向通用收集
原标题:Converting TObjectList ancestor to generic collection in Delphi

一等

TMyAwesomeList = class(TObjectList)

搁置

 TAwesomeItem = class(TPersistent)

坦布 项目相当抽象。

 TAwesomeItem1 = class(TAwesomeItem)
 TAwesomeItem2 = class(TAwesomeItem)
 TAwesomeItem3 = class(TAwesomeItem)
 TAwesomeItem3a = class(TAwesomeItem3)

等等(约有30个分级,有几门中等抽象的班级),一年前完成一些专题关系模型,预计最终将从Delphi 7转变至2009年(以及很快的XE2)。

该法典仍然在2009年德尔菲开展工作,但我想做的是

 for AwesomeItem3a in AwesomeList do
 begin     
    //something awesome
 end;

我不知道如何改组泰米尔伊拉姆猛虎人组织(或增加几个子类别),以完成这项工作。

最佳回答

Based on your comments, it seems you can simply use TObjectList directly.

var
  MyAwesomeList1: TObjectList<TMyAwesomeItem1>;
  MyAwesomeItem1: TMyAwesomeItem1;
begin
  MyAwesomeList1 := TObjectList<TMyAwesomeItem1>.Create;
  try
    // populate the list...

    for MyAwesomeItem1 in MyAwesomeList1 do
      ...
  finally
    MyAwesomeList1.Free;
  end;
end;

... and same for TMyAwesomeItem2, etc. If you prefer, you can also declare a type alias:

type
  TMyAwesomeList1 = TObjectList<TMyAwesomeItem1>;
  TMyAwesomeList2 = TObjectList<TMyAwesomeItem2>;
  // etc.
问题回答

暂无回答




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签