public Write ( byte buffer, int offset, int count ) : void | ||
buffer | byte | |
offset | int | |
count | int | |
return | void |
public static PooledMemoryStream From(Stream stream, int length) { var total = 0; PooledMemoryStream destination = null; byte[] buffer = bufferManager.TakeBuffer(4096); try { int read; destination = new PooledMemoryStream(); while ((read = stream.Read(buffer, 0, Math.Min(buffer.Length, length - total))) != 0) { total += read; destination.Write(buffer, 0, read); } return destination; } catch { if(destination!=null) destination.Dispose(); throw; } finally { bufferManager.ReturnBuffer(buffer); } }
public static PooledMemoryStream From(Stream stream, int length) { var total = 0; PooledMemoryStream destination = null; byte[] buffer = bufferManager.TakeBuffer(4096); try { int read; destination = new PooledMemoryStream(); while ((read = stream.Read(buffer, 0, Math.Min(buffer.Length, length - total))) != 0) { total += read; destination.Write(buffer, 0, read); } return(destination); } catch { if (destination != null) { destination.Dispose(); } throw; } finally { bufferManager.ReturnBuffer(buffer); } }