using System; namespace SK.Framework { /// /// 单例 /// /// public static class Singleton where T : class, ISingleton { private static T instance; private static readonly object _lock = new object(); public static T Instance { get { lock (_lock) { if(null == instance) { instance = Activator.CreateInstance(); instance.OnInit(); } } return instance; } } public static void Dispose() { instance = null; } } }