Files
hjha-server/ServerCore/SingleInstance/ASingleton.cs
xiaoou e9616125ce feat: initial commit - HJHA game server full source
6 major server modules (PdkFriendServer/GlobalSever/ServerCore/GameModule/GameNetModule) +
game logic (GameFix/GameDAL/ServerData) +
network layer (NetWorkMessage) +
data layer (ObjectModel) +
utilities (MrWu/Core/Config/CloudAPI/dll) +
adapters (zyxAdapter/base)

.NET 8.0 C# solution, 16 projects, 958 source files
2026-07-07 12:02:15 +08:00

67 lines
1.3 KiB
C#

using System;
using MrWu.Debug;
namespace Server.Core
{
public abstract class ASingleton : IDisposable
{
public abstract void Register();
public virtual void Dispose()
{
}
}
public abstract class Singleton<T> : ASingleton where T : Singleton<T>
{
private bool isDisposed;
private static T instance;
public static T Instance
{
get
{
return instance;
}
private set
{
instance = value;
}
}
public override void Register()
{
Instance = (T)this;
Instance.Awake();
}
public bool IsDisposed()
{
return this.isDisposed;
}
protected virtual void Awake()
{
}
protected virtual void Destroy()
{
}
public override void Dispose()
{
if (this.isDisposed)
{
return;
}
this.isDisposed = true;
this.Destroy();
Instance = null;
}
}
}