using System;

public class Singleton<T> where T : class, new()
{
    private static T _Instance;

    public static T Instance
    {
        get
        {
            if (_Instance == null) _Instance = Activator.CreateInstance<T>();
            return _Instance;
        }
    }
// 移除主动Singleton的功能。
//    static Singleton()
//    {
//        Singleton<T>._Instance = new T();
//    }

    public static void CreateInstance()
    {
        if (_Instance == null) _Instance = Activator.CreateInstance<T>();
    }

    public static void DestroyInstance()
    {
        _Instance = null;
    }

    public static T GetInstance()
    {
        return Instance;
    }
}