Esempio n. 1
0
 public void ReturnInstance(object instance)
 {
     ReturnInstanceMethod?.Invoke(instance);
     if (objectStack.Count < targetCount)
     {
         objectStack.Push(instance);
     }
     else
     {
         DisposeInstanceMethod?.Invoke(instance);
     }
 }
Esempio n. 2
0
        public void CreateInstance(int count)
        {
            if (count == 0)
            {
                return;
            }

            this.targetCount += count;
            for (int i = 0; i < count; ++i)
            {
                object instance = CreateInstanceMethod();
                ReturnInstanceMethod?.Invoke(instance);
                objectStack.Push(instance);
            }
        }