using System; namespace S3Demo.Helper { /// /// 单例模式 /// /// //new(),new不支持非公共的无参构造函数 // Token: 0x0200016F RID: 367 public abstract class SingletonHelper where T : class { private static T sInstance; /// /// 创建获取实例 /// /// public static T Instance() { Type typeFromHandle = typeof(T); lock (typeFromHandle) { if (SingletonHelper.sInstance == null) { SingletonHelper.sInstance = (Activator.CreateInstance(typeof(T), true) as T); } } return SingletonHelper.sInstance; } } }