/// <summary> /// Retrieve a new MemoryStream object with the given tag and with contents copied from the provided /// buffer. The provided buffer is not wrapped or used after construction. /// </summary> /// <remarks>The new stream's position is set to the beginning of the stream when returned.</remarks> /// <param name="tag">A tag which can be used to track the source of the stream.</param> /// <param name="buffer">The byte buffer to copy data from.</param> /// <param name="offset">The offset from the start of the buffer to copy from.</param> /// <param name="count">The number of bytes to copy from the buffer.</param> /// <returns>A MemoryStream.</returns> //[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] public MemoryStream GetStream(string tag, byte[] buffer, int offset, int count) { var stream = new RecyclableMemoryStream(this, tag, count); stream.Write(buffer, offset, count); stream.Position = 0; return stream; }