예제 #1
0
        private IPoolAble CreateNew(InstantiationMethod instantiationMethod)
        {
            IPoolAble poolAble = instantiationMethod(this);

            poolAble.Inactivated += PoolAble_Inactivated;
            return(poolAble);
        }
예제 #2
0
        public void Init(int hashCode, InstantiationMethod instantiationMethod, int min = 10, int max = 20)
        {
            if (!pools.ContainsKey(hashCode))
            {
                PoolingElementContext poolingElementContext = new PoolingElementContext();
                poolingElementContext.InstationMethod = instantiationMethod;
                poolingElementContext.Min             = min;
                poolingElementContext.Max             = max;
                poolingElementContext.PoolingObjects  = new List <IPoolAble>();
                pools.Add(hashCode, poolingElementContext);

                List <IPoolAble> poolAbles = pools[hashCode].PoolingObjects;

                for (int i = 0; i < min; i++)
                {
                    IPoolAble poolAble = CreateNew(instantiationMethod);
                    poolAbles.Add(poolAble);
                }
            }
        }