Design Patterns – Generic Singleton Pattern
Gepost op 2008.07.15 | Reacties (3) | C#, Design Patterns, Technologie
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.
I’d like this post to draw some attention from CLR guru’s to have a look at the implementation and point out possible problems and how to solve them.








[...] more at http://blog.cumps.be/design-patterns-generic-singleton-pattern/ Filed under: C#, General Software Development, Visual Studio, .NET, Design [...]
[...] Design Patterns – Generic Singleton Pattern – David Cumps [...]
[...] Design Patterns – Generic Singleton Pattern [...]