I've been coding a bunch of singletons lately. Don't know, but maybe it's just a fad but a lot of classes only need to allow a singleobject. The pattern I usually use is the following:
public class Foo
{
private static Foo instance = new Foo();
public static Foo Instance
{
get { return instance; }
}
protected Foo() {}
}
Acces to the single object is then through the property as:
Foo.Instance.<methodname>
I'mjust thinking that this is way too much typing. A wrist friendlylanguage (to quote the creator of 'boo'). I'd like to see thefollowing type of syntax for declaring a singleton class:
[Singleton]
public class Foo {}
The compiler / runtime should use the attribute to autogenerate the protected constructor, private member, and public property.
46c396e9-8115-49f7-855f-cf264935a565|0|.0