static ObjectAllocators() { GetAllocator(typeof(MemoryStream)).Factory = new MemoryStreamObjectFactory(); foreach (var customAbstractObjectFactory in FindAllGameComponentType()) { var type = customAbstractObjectFactory.Type; _allocatorDic[type] = new RingBufferObjectAllocator(customAbstractObjectFactory, customAbstractObjectFactory.InitPoolSize); } }
public static IObjectAllocator GetAllocator(Type type) { IObjectAllocator rc; if (!_allocatorDic.TryGetValue(type, out rc)) { rc = new RingBufferObjectAllocator(new DefaultObjectFactory(type)); _allocatorDic[type] = rc; } return(rc); }