publicclassPoolTest:Test{publicinterfaceIObject{}publicclassObj_A:IObject{}publicclassObj_B:IObject{}privatevoidFastExample(){
Log.L("Create a auto create pool");ActivatorCreatePool<Obj_A> pool =newActivatorCreatePool<Obj_A>();
Log.L("Get an instance from pool");var _obj = pool.Get();
Log.L($"the type of instance is {_obj.GetType()}");
Log.L("Let's put the instance to pool");
pool.Set(_obj);}privateclassMyPool:ObjectPool<Obj_A>{protectedoverrideObj_ACreatNew(IEventArgs arg){returnnewObj_A();}}privatevoidNormalTest(){
Log.L("Create a auto create pool");MyPool pool =newMyPool();
Log.L("Get an instance from pool");var _obj = pool.Get();
Log.L($"the type of instance is {_obj.GetType()}");
Log.L("Let's put the instance to pool");
pool.Set(_obj);}privateclassMutiPool:BaseTypePool<IObject>{}privatevoidMutiTest(){
Log.L("Create a auto create pool");MutiPool pool =newMutiPool();
Log.L("Get an instance A from pool");IObject _obj = pool.Get<Obj_A>();
Log.L($"the type of instance is {_obj.GetType()}");
Log.L("Let's put the instance to pool");
pool.Set(_obj);
Log.L("Get an instance B from pool");
_obj = pool.Get<Obj_B>();
Log.L($"the type of instance is {_obj.GetType()}");
Log.L("Let's put the instance to pool");
pool.Set(_obj);}protectedoverridevoidStart(){
Log.L("--------------------------");FastExample();
Log.L("--------------------------");NormalTest();
Log.L("--------------------------");MutiTest();}protectedoverridevoidStop(){}protectedoverridevoidUpdate(){}}