public static string Print() { StringBuilder stringBuilder = new StringBuilder(4096); stringBuilder.AppendFormat("Use Pool : {0}\n", NrTSingleton <NrGlobalReference> .Instance.usePool); foreach (KeyValuePair <ObjectPoolKey, IObjectPoolContainer> current in ObjectPoolManager.ms_ObjPools) { ObjectPoolKey key = current.Key; IObjectPoolContainer value = current.Value; stringBuilder.AppendFormat("{0}, {1}\n", key.ToString(), value.ToString()); } return(stringBuilder.ToString()); }
private static T Acquire <T>(ObjectPoolKey data, object param) where T : class, IPoolObject { Type typeFromHandle = typeof(T); IObjectPoolContainer objectPoolContainer = ObjectPoolManager.I_GetObjectPoolContainer(data); TsLog.Assert(objectPoolContainer != null, "ObjectPoolConatiner is not found for {0} class.", new object[] { typeFromHandle.Name }); T t = (T)((object)null); if (objectPoolContainer == null) { TsLog.Assert(false, "ObjectPoolManager. Class {0} poolContainer is null", new object[] { typeFromHandle.Name }); } else if (objectPoolContainer.objectPoolAttr == null) { TsLog.Assert(false, "ObjectPoolManager. ObjectPoolAttribute for class {0} is null", new object[] { typeFromHandle.Name }); } else if (objectPoolContainer.objectPoolAttr.CreateObjectStaticPrivate == null) { TsLog.Assert(false, "{0} class ObjectPoolAttribute.CreateInstance is not found!", new object[] { typeFromHandle.Name }); } else { t = (objectPoolContainer.Acquire() as T); if (t == null) { TsLog.LogError("ObjectPoolManager.Acquire<T>(). Fail creation {0}.", new object[] { typeFromHandle.Name }); } else { t.OnCreate(param); } } return(t); }