This project has moved. For the latest updates, please go here.

singleton?

Feb 16, 2010 at 8:01 PM

Does the csd generated code provide true singleton behaviour and do I get this behaviour by default if I simply use the generated code like:

MyConfig.MyListOfStuff

?

 

Cheers in advance -  great piece of kit so far!

Coordinator
Feb 18, 2010 at 8:48 AM

I'm not sure what you mean when you ask for singleton behavior. Would you please elaborate? Which behavior are you looking for, exactly?

Feb 18, 2010 at 8:55 AM

Hi,

I mean singleton behaviour in the Gang of Four design pattern sense. For example, when I access any of my config elements, singleton behaviour would ensure that one and only one instance of the config class would ever be instantiated and responsible for returning the elements.

The reason I ask is that I noticed a method called 'GetSingletonInstance' in the generated code, and this made me realise I might not have to design in my own singleton behaviour around the generated code.

Cheers.

Coordinator
Feb 18, 2010 at 9:34 AM

I've never seen the GetSingletonInstance method you speak of. The CSD code generator creates a property called Instance. I'm not sure if it truly is a singleton; it was added before I started working on the project. It is very easy to test, however. Just make two calls to the property, so you have two variables that hold your configuration section, then modify a value in one of them and check that it's been modified in the other one.

Feb 18, 2010 at 3:06 PM

Tried it - and it is exhibiting singleton behaviour

bravo!