public override byte[] TakeBuffer(int bufferSize)
 {
     InternalBufferManager.PooledBufferManager.BufferPool pool = this.FindPool(bufferSize);
     byte[] numArray1;
     if (pool != null)
     {
         byte[] numArray2 = pool.Take();
         if (numArray2 != null)
         {
             pool.DecrementCount();
             numArray1 = numArray2;
         }
         else
         {
             if (pool.Peak == pool.Limit)
             {
                 ++pool.Misses;
                 if (++this.totalMisses >= 8)
                 {
                     this.TuneQuotas();
                 }
             }
             numArray1 = Fx.AllocateByteArray(pool.BufferSize);
         }
     }
     else
     {
         numArray1 = Fx.AllocateByteArray(bufferSize);
     }
     return(numArray1);
 }
            private void ChangeQuota(ref InternalBufferManager.PooledBufferManager.BufferPool bufferPool, int delta)
            {
                InternalBufferManager.PooledBufferManager.BufferPool bufferPool1 = bufferPool;
                int limit = bufferPool1.Limit + delta;

                InternalBufferManager.PooledBufferManager.BufferPool pool = InternalBufferManager.PooledBufferManager.BufferPool.CreatePool(bufferPool1.BufferSize, limit);
                for (int index = 0; index < limit; ++index)
                {
                    byte[] buffer = bufferPool1.Take();
                    if (buffer != null)
                    {
                        pool.Return(buffer);
                        pool.IncrementCount();
                    }
                    else
                    {
                        break;
                    }
                }
                this.remainingMemory -= (long)(bufferPool1.BufferSize * delta);
                bufferPool            = pool;
            }