Page 1 of 1

Global state objects

Posted: Fri Feb 24, 2012 6:49 pm
by andrewn
Hello,

I'm looking for where to store references to some .NET runtime objects which get initialized in the first module of the test suite, and are shared across all modules, up until the end of the test.

The main repository seems to be a proper place to store global variables like that. But repository vars seem to be limited to strings only, while I need to keep live objects in there. I'd hate creating a static member of the Program class. There should be a better way to share the state between modules.

I apologize if that's been answered before, could not find it.

Thanks,
Andrew.

Re: Global state objects

Posted: Mon Feb 27, 2012 4:06 pm
by Support Team
Hi,
andrewn wrote:The main repository seems to be a proper place to store global variables like that. But repository vars seem to be limited to strings only, while I need to keep live objects in there. I'd hate creating a static member of the Program class. There should be a better way to share the state between modules.
If you want to use global state objects you should implement a singleton. Therefore please take a look to following link http://msdn.microsoft.com/en-us/library/ff650316.aspx

Regards,
Peter
Ranorex Team

Re: Global state objects

Posted: Wed Feb 29, 2012 4:39 pm
by andrewn
Support Team wrote:Hi,

If you want to use global state objects you should implement a singleton. Therefore please take a look to following link http://msdn.microsoft.com/en-us/library/ff650316.aspx
Thanks for replying, Peter. Singletons are effectively global static variables, like FusionRepository.Instance, but I can live with that.