public class SingletonFactory<T> where T : new()
{
public static T GetInstance()
{
return SingletonCreator.Instance;
}
private static class SingletonCreator
{
private static T _instance;
private static readonly object syncRoot = new Object();
public static T Instance
{
get
{
if (_instance == null)
{
lock (syncRoot)
{
if (_instance == null)
{
_instance = new T();
}
}
}
return _instance; }
}
}
}