diff options
| author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
|---|---|---|
| committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
| commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
| tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XUtliPoolLib/XInterfaceMgr.cs | |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XUtliPoolLib/XInterfaceMgr.cs')
| -rw-r--r-- | Client/Assets/Scripts/XUtliPoolLib/XInterfaceMgr.cs | 54 |
1 files changed, 54 insertions, 0 deletions
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<XInterfaceMgr>
+ {
+ private Dictionary<uint, IXInterface> _interfaces = new Dictionary<uint, IXInterface>();
+
+ public T GetInterface<T>(uint key) where T : IXInterface
+ {
+ IXInterface ixinterface = null;
+ this._interfaces.TryGetValue(key, out ixinterface);
+ return (T)((object)ixinterface);
+ }
+
+ public T AttachInterface<T>(uint key, T value) where T : IXInterface
+ {
+ bool flag = this._interfaces.ContainsKey(key);
+ if (flag)
+ {
+ this._interfaces[key].Deprecated = true;
+ XSingleton<XDebug>.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();
+ }
+ }
+}
|
