如何在DWScript中使用循环引用注册两个类?

时间:2016-09-23 07:37:30

标签: dwscript

我需要注册TCollection和TCollectionItem类,但由于

的属性
{TCollection}
property Items [Index: Integer]: TCollectionItem
{TCollectionItem}
property Collection: TCollection

显然提出了找不到TCollectionItem / TCollectionItem类型的例外情况。

2 个答案:

答案 0 :(得分:0)

如果您在代码中自行注册课程,则可以先注册TCollectionItem而不注册property Collection: TCollection,然后使用TCollection注册property Items [Index: Integer]: TCollectionItem,然后添加{ {1}} property Collection: TCollection

答案 1 :(得分:0)

您可以使用:

type
  TCollection = class;

  TCollectionItem = class
  published
    property Items: TCollection;
  end;

  TCollection = class
  published
    property Items [Index: Integer]: TCollectionItem;
  end;