Thursday, May 27, 2010

Generic Singleton

****

What was I thinking, if I use any regular class here, it will not be singleton as you could always new() up an instance.

****
Once and for all, I am going to settle with this implementation of singleton.

https://www.assembla.com/code/TechnologyAndMe/subversion/nodes/Singleton
(Download complete source using a SVN client from http://subversion.assembla.com/svn/TechnologyAndMe/Singleton )

Singleton is now as easy as:
var instance = Singleton<SomeOtherClass>.Instance;

No comments: