From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XUtliPoolLib/XInterfaceMgr.cs | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XInterfaceMgr.cs (limited to 'Client/Assets/Scripts/XUtliPoolLib/XInterfaceMgr.cs') diff --git a/Client/Assets/Scripts/XUtliPoolLib/XInterfaceMgr.cs b/Client/Assets/Scripts/XUtliPoolLib/XInterfaceMgr.cs new file mode 100644 index 00000000..38bfaece --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XInterfaceMgr.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; + +namespace XUtliPoolLib +{ + public class XInterfaceMgr : XSingleton + { + private Dictionary _interfaces = new Dictionary(); + + public T GetInterface(uint key) where T : IXInterface + { + IXInterface ixinterface = null; + this._interfaces.TryGetValue(key, out ixinterface); + return (T)((object)ixinterface); + } + + public T AttachInterface(uint key, T value) where T : IXInterface + { + bool flag = this._interfaces.ContainsKey(key); + if (flag) + { + this._interfaces[key].Deprecated = true; + XSingleton.singleton.AddLog("Duplication key for interface ", this._interfaces[key].ToString(), " and ", value.ToString(), null, null, XDebugColor.XDebug_None); + this._interfaces[key] = value; + } + else + { + this._interfaces.Add(key, value); + } + this._interfaces[key].Deprecated = false; + return value; + } + + public void DetachInterface(uint key) + { + bool flag = this._interfaces.ContainsKey(key); + if (flag) + { + this._interfaces[key].Deprecated = true; + this._interfaces.Remove(key); + } + } + + public override bool Init() + { + return true; + } + + public override void Uninit() + { + this._interfaces.Clear(); + } + } +} -- cgit v1.1-26-g67d0