简体   繁体   English

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

[英]How registrate two class with circular references in DWScript?

I need to register TCollection and TCollectionItem classes, but because of the properties of我需要注册 TCollection 和 TCollectionItem 类,但由于

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

сonstantly raises the exception of the impossibility to find TCollectionItem/TCollectionItem type. с不断引发无法找到 TCollectionItem/TCollectionItem 类型的异常。

如果你对你自己的代码内注册类,你可以先注册TCollectionItem没有property Collection: TCollection ,然后注册TCollectionproperty Items [Index: Integer]: TCollectionItem事后添加的property Collection: TCollectionTCollectionItem

You can use:您可以使用:

type
  TCollection = class;

  TCollectionItem = class
  published
    property Items: TCollection;
  end;

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM