如何管理delphi单元中的循环引用? [英] How to manage circular references in delphi units?
问题描述
AfterSignup.Show;
但问题是我有义务将AfterSignup单元添加到BeforeSignup的使用列表中,正是我无法做的,因为我是使用BeforeSignup to AfterSignup单位的alreadey。
我收到一个错误说,循环单位的参考。
简单的解决方案是在中添加
unitA
c
中的code>使用
实现
部分 unitA $
c $ c>
更好的解决方案是为两(或至少一个)单位破坏依赖关系。
您可以通过
- 将所有来自
unitA
的所有呼叫分解为依赖关系unitB
intounitB
- 添加第三个共享代码单元单位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
tounitB
intounitB
- adding a third, shared code unit, using both
units A & B
.
这篇关于如何管理delphi单元中的循环引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!