Skip to content

Instantly share code, notes, and snippets.

@spartawhy117
Last active August 21, 2020 12:06
Show Gist options
  • Save spartawhy117/2ab2c5d9166220de66ab69c426e2ada8 to your computer and use it in GitHub Desktop.
Save spartawhy117/2ab2c5d9166220de66ab69c426e2ada8 to your computer and use it in GitHub Desktop.
c# 设计模式
public class SingletonTemplate<T> where T : class, new()
{
private static T mSingleton;
public static T Singleton
{
get
{
if (mSingleton == null)
{
ProfilerTimer.begin();
mSingleton = new T();
ProfilerTimer.end(typeof(T).Name);
}
return mSingleton;
}
}
}
//使用例子
public partial class ResManger : SingletonTemplate<ResManger>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment