diff options
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();
+ }
+ }
+}
|