You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
696 B
34 lines
696 B
using System;
|
|
|
|
namespace Sog
|
|
{
|
|
public abstract class Singleton<T> where T : class, new()
|
|
{
|
|
private static T _instance;
|
|
private static readonly object syslock = new object();
|
|
|
|
protected Singleton()
|
|
{
|
|
}
|
|
|
|
public static T Instance
|
|
{
|
|
get
|
|
{
|
|
if (_instance == null)
|
|
{
|
|
lock (syslock)
|
|
{
|
|
if (_instance == null)
|
|
{
|
|
_instance = new T();
|
|
}
|
|
}
|
|
}
|
|
return _instance;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|