Design Patterns - Generic Singleton Pattern
Originally published on my old blog at cumps.be on July 15, 2008.
A little follow up from yesterday’s Singleton Pattern, where I asked for some help on how you would approach a generic singleton.
With the help of Andrew Stevenson and ExNihilo, we came up with the following Generic Singleton Pattern:

Using Reflection, the private constructor is called to create an instance of the class.
Whenever a Singleton is needed now, the only thing to do is to inherit Singleton and pass in the class itself as T, along with making the constructor private.
I’ve updated yesterday’s solution to contain this new code as well, have a look.
You May Also Like
Design Patterns - Command Pattern
What's a lonely geek to do late in the evening? Write about the Command Pattern of course...
Design Patterns - Singleton Pattern
Today we'll have a look at a well known pattern, the Singleton Pattern. Most people have already heard about this one.
Design Patterns - Abstract Factory Pattern
Time to continue from yesterday's Factory Method Pattern by exploring the Abstract Factory Pattern.



