Beispiel #1
0
 public StreamFormatter(Stream stream, FormattingData formattingData, ManagedBufferPool <byte> pool, int bufferSize = 256)
 {
     _pool   = pool;
     _buffer = null;
     if (bufferSize > 0)
     {
         _buffer = _pool.RentBuffer(bufferSize);
     }
     _formattingData = formattingData;
     _stream         = stream;
 }
Beispiel #2
0
 public BufferFormatter(int capacity, FormattingData formattingData, ManagedBufferPool <byte> pool = null)
 {
     _formattingData = formattingData;
     _count          = 0;
     _pool           = pool;
     if (_pool == null)
     {
         _pool = new ManagedBufferPool <byte>(capacity);
     }
     _buffer = _pool.RentBuffer(capacity);
 }
Beispiel #3
0
 public ArraySegment <byte> GetFreeBuffer(int minBytes)
 {
     if (this._buffer == null)
     {
         this._buffer = pool.RentBuffer(minBytes);
     }
     else if (this._buffer.Length < minBytes)
     {
         pool.EnlargeBuffer(ref this._buffer, minBytes);
     }
     return(new ArraySegment <byte>(this._buffer));
 }
Beispiel #4
0
 public MemoryWriter()
 {
     this._buffer = pool.RentBuffer(64);
 }
 public StringFormatter(int capacity, ManagedBufferPool <byte> pool)
 {
     _pool   = pool;
     _buffer = _pool.RentBuffer(capacity * 2);
 }