ball 项目提交
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class Singleton<T> : ISingleton, IDisposable where T : Singleton<T>, new()
|
||||
{
|
||||
private static T mInstance;
|
||||
|
||||
private static readonly object LockObject = new();
|
||||
|
||||
public static T Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
mInstance ??= new T();
|
||||
mInstance.OnSingletonInit();
|
||||
}
|
||||
|
||||
return mInstance;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
mInstance = null;
|
||||
}
|
||||
|
||||
public void OnSingletonInit()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user