Global state objects

Ask general questions here.
andrewn
Posts: 5
Joined: Fri Feb 24, 2012 6:32 pm

Global state objects

Post by andrewn » Fri Feb 24, 2012 6:49 pm

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Global state objects

Post by Support Team » Mon Feb 27, 2012 4:06 pm

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

andrewn
Posts: 5
Joined: Fri Feb 24, 2012 6:32 pm

Re: Global state objects

Post by andrewn » Wed Feb 29, 2012 4:39 pm

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.