using System; using System.Collections.Generic; using XUtliPoolLib; namespace XMainClient { internal class XEventPool where T : XEventArgs, new() { private static Queue _pool = null; public static void Clear() { bool flag = XEventPool._pool != null; if (flag) { XEventPool._pool.Clear(); XEventPool._pool = null; } } public static T GetEvent() { bool flag = XEventPool._pool == null; if (flag) { XEventPool._pool = new Queue(); XSingleton.singleton.RegisterEventPool(new EventPoolClear(XEventPool.Clear)); } bool flag2 = XEventPool._pool.Count > 0; T result; if (flag2) { T t = XEventPool._pool.Dequeue(); bool flag3 = t == null; if (flag3) { XSingleton.singleton.AddErrorLog("XEvent Type should be ", typeof(T).ToString(), " but is ", t.ToString(), null, null); } t.Token = XSingleton.singleton.UniqueToken; result = t; } else { result = Activator.CreateInstance(); } return result; } public static void Recycle(T args) { XEventPool._pool.Enqueue(args); } } }