On 2016-03-31 16:46, Dmitry Boyarintsev wrote: > One could use an alternative approach and have "binding" units. > The unit would consist of initialization section only, that does the > necessary binding code.
tiOPF's TestSuite project has a tiTestDependencies.pas unit which primarily consists of a large uses clause and a procedure called tiRegisterTests eg: procedure tiRegisterTests; begin ...snip... GTIOPFManager.DefaultOIDGenerator:= TtiOIDGeneratorForTesting.Create; tiBaseObject_TST.RegisterTests; tiUtils_TST.RegisterTests; tiRTTI_TST.RegisterTests; ...snip... end; Each *_TST.pas unit defines a global RegisterTests() method than needs to be called before that unit is activated. In the framework side we have a unit that registers various logging output formats. Again a tiLogReg.pas unit is used, but this time its inititialization section activates all the dependency logging classes. This whereas with the test framework the tiRegisterTests procedure needed to be called, with the tiLogReg you just need to have it somewhere in your program unit's uses clause. ======================== unit tiLogReg; {$I tiDefines.inc} interface implementation uses tiLog // ,tiConstants { ToDo: We should move log constant to this unit. } ,tiCommandLineParams ,tiLogToFile ,tiLogToGUI ,tiLogToConsole ; initialization if gCommandLineParams.IsParam(csLog) or gCommandLineParams.IsParam(csLogVisual) then GLog.RegisterLog(TtiLogToFile.Create); if gCommandLineParams.IsParam(csLogVisual) then GLog.RegisterLog(TtiLogToGUI.Create); if gCommandLineParams.IsParam(csLogConsole) then GLog.RegisterLog(TtiLogToConsole.Create); ======================== Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal