Do I still have to implement a singleton class by hand in .net, even when using .Net4.0?

Posted by Hamish Grubijan on Stack Overflow See other posts from Stack Overflow or by Hamish Grubijan
Published on 2010-04-27T19:53:26Z Indexed on 2010/04/27 20:03 UTC
Read the original article Hit count: 264

Filed under:
|

Once the singleton pattern is understood, writing subsequent singleton classes in C# is a brainless exercise. I would hope that the framework would help you by providing an interface or a base class to do that. Here is how I envision it:

public sealed class Schablone : ISingleton<Schablone>
{
    // Stuff forced by the interface goes here

    // Extra logic goes here
}

Does what I am looking for exist?

Is there some syntactic sugar for constructing a singleton class - whether with an interface, a class attribute, etc.?

Can one write a useful and bullet-proof ISingleton themselves? Care to try?

Thanks!

© Stack Overflow or respective owner

Related posts about .net-4.0

Related posts about singleton-class