35 lines
671 B
C#
35 lines
671 B
C#
using System;
|
|
public abstract class DataSingleton<T> where T : class, new()
|
|
{
|
|
private static T m_instance;
|
|
public static T Instance
|
|
{
|
|
get
|
|
{
|
|
if (DataSingleton<T>.m_instance == null)
|
|
{
|
|
DataSingleton<T>.m_instance = Activator.CreateInstance<T>();
|
|
if (DataSingleton<T>.m_instance != null)
|
|
{
|
|
(DataSingleton<T>.m_instance as DataSingleton<T>).Init();
|
|
}
|
|
}
|
|
|
|
return DataSingleton<T>.m_instance;
|
|
}
|
|
}
|
|
public static void Release()
|
|
{
|
|
if (DataSingleton<T>.m_instance != null)
|
|
{
|
|
DataSingleton<T>.m_instance = (T) ((object) null);
|
|
}
|
|
}
|
|
public void Startup()
|
|
{
|
|
}
|
|
public abstract void Init();
|
|
public abstract void OnDispose();
|
|
}
|
|
|