public T GetOrCreate <T>(ProtoRecycleType type) where T : ProtoBase, new() { T result = Get <T>(type); if (result == null) { result = new T(); } return(result); }
public void Recycle(ProtoRecycleType type, ProtoBase proto) { Stack <ProtoBase> stack; if (!pool.TryGetValue(type, out stack)) { stack = new Stack <ProtoBase>(); stack.Push(proto); } stack.Push(proto); }
public T Get <T>(ProtoRecycleType type) where T : ProtoBase, new() { Stack <ProtoBase> stack; T result = default(T); if (pool.TryGetValue(type, out stack)) { ProtoBase p = null; p = stack.Pop(); if (p != null) { result = p as T; } } return(result); }