From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XUtliPoolLib/XSingleton.cs | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XSingleton.cs (limited to 'Client/Assets/Scripts/XUtliPoolLib/XSingleton.cs') diff --git a/Client/Assets/Scripts/XUtliPoolLib/XSingleton.cs b/Client/Assets/Scripts/XUtliPoolLib/XSingleton.cs new file mode 100644 index 00000000..df9e221d --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XSingleton.cs @@ -0,0 +1,36 @@ +using System; + +namespace XUtliPoolLib +{ + public abstract class XSingleton : XBaseSingleton where T : new() + { + public static T singleton + { + get + { + return XSingleton._instance; + } + } + + private static readonly T _instance = Activator.CreateInstance(); + + protected XSingleton() + { + bool flag = XSingleton._instance != null; + if (flag) + { + T instance = XSingleton._instance; + throw new XDoubleNewException(instance.ToString() + " can not be created again."); + } + } + + public override bool Init() + { + return true; + } + + public override void Uninit() + { + } + } +} -- cgit v1.1-26-g67d0