如何管理delphi单元中的循环引用? [英] How to manage circular references in delphi units?

查看:472
本文介绍了如何管理delphi单元中的循环引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在AfterSignup单元中使用BeforSignup,以便能够从AfterSignup代码中调用电子邮件变量,最后我引用了一个问题,因为我想使用以下代码打开AfterSignup窗口的按钮:

  AfterSignup.Show; 

但问题是我有义务将AfterSignup单元添加到BeforeSignup的使用列表中,正是我无法做的,因为我是使用BeforeSignup to AfterSignup单位的alreadey。



我收到一个错误说,循环单位的参考。

解决方案

简单的解决方案是在中添加 unitA c c c c c c 中的code>使用实现部分 unitA c $ c>



更好的解决方案是为两(或至少一个)单位破坏依赖关系

您可以通过




  • 将所有来自 unitA 的所有呼叫分解为依赖关系 unitB into unitB

  • 添加第三个共享代码单元单位A& B


I am using the BeforSignup in the AfterSignup unit in order to be able to call the email variable from within AfterSignup code, finally i enbcountred a problem because i want to make a button which opens the AfterSignup window using the code :

 AfterSignup.Show;

But the problem is that i am obliged to add the AfterSignup unit to the uses list of BeforeSignup and that is exactly what i can't do because i am alreadey using BeforeSignup to AfterSignup unit.

i receive an error saying, a reference of circular unit.

解决方案

The easy solution would be to add unitA in the uses clause of the interface section of unitB and unitB in the uses clause of the implementation section of unitA

The better solution would be to break the dependency for both (or at least one) units.
You can break the dependency by either

  • moving all calls from unitA to unitB into unitB
  • adding a third, shared code unit, using both units A & B.

这篇关于如何管理delphi单元中的循环引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆