Last active
August 21, 2020 12:06
-
-
Save spartawhy117/2ab2c5d9166220de66ab69c426e2ada8 to your computer and use it in GitHub Desktop.
c# 设计模式
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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